Part Number Hot Search : 
VY1C3 MA3SE02 DTC11 MB3793 DRA4152Z 21200 167BZXI BD302
Product Description
Full Text Search
 

To Download W78E052DDG Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 1 - revision a1 3 table of contents - 1 general description ................................ ................................ ................................ ......... 4 2 features ................................ ................................ ................................ ................................ . 5 3 parts inform ation list ................................ ................................ ................................ ..... 6 4 pin configurations ................................ ................................ ................................ ............. 7 5 pin descriptions ................................ ................................ ................................ .................. 9 6 block diagram ................................ ................................ ................................ .................... 11 7 functional descripti on ................................ ................................ ................................ .. 12 7.1 on - chip flash eprom ................................ ................................ ................................ 12 7.2 i/o ports ................................ ................................ ................................ ........................ 12 7.3 serial i/o ................................ ................................ ................................ ....................... 12 7.4 timers ................................ ................................ ................................ ........................... 12 7.5 interrup ts ................................ ................................ ................................ ....................... 12 7.6 data pointers ................................ ................................ ................................ ................ 12 7.7 architecture ................................ ................................ ................................ ................... 13 7.7.1 alu ................................ ................................ ................................ ................................ 13 7.7.2 accumulator ................................ ................................ ................................ ................... 13 7.7.3 b register ................................ ................................ ................................ ....................... 13 7.7.4 program status word ................................ ................................ ................................ ..... 13 7.7.5 scratch - pad ram ................................ ................................ ................................ ........... 13 7.7.6 stack pointer ................................ ................................ ................................ .................. 13 8 memory organ ization ................................ ................................ ................................ ...... 14 8.1 program memory (on - chip flash) ................................ ................................ ................. 14 8.2 scratch - pad ram and register map ................................ ................................ ............ 14 8.2.1 working registers ................................ ................................ ................................ .......... 16 8.2.2 bit addressable locations ................................ ................................ .............................. 17 8.2.3 stack ................................ ................................ ................................ .............................. 17 9 special function reg isters ................................ ................................ .......................... 18 9.1 sfr detail bit descriptions ................................ ................................ .......................... 20 10 instruction ................................ ................................ ................................ .......................... 34 10.1 instruction timing ................................ ................................ ................................ .......... 42 11 power management ................................ ................................ ................................ .......... 43 11.1 idle mode ................................ ................................ ................................ ...................... 43 11.2 power down mode ................................ ................................ ................................ ........ 43 12 reset conditions ................................ ................................ ................................ ............... 44 12.1 sources of re set ................................ ................................ ................................ ............ 44 12.1.1 external reset ................................ ................................ ................................ .............. 44 12.1.2 software reset ................................ ................................ ................................ ............. 44 12.1.3 watchdog timer reset ................................ ................................ ................................ . 44 12.2 reset state ................................ ................................ ................................ ................... 44 13 interrupts ................................ ................................ ................................ ........................... 45 13. 1 interrupt sources ................................ ................................ ................................ .......... 45
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 2 - revision a1 3 13.2 priority level structure ................................ ................................ ................................ . 45 13.3 interrupt response time ................................ ................................ .............................. 47 13.4 interrupt inputs ................................ ................................ ................................ .............. 48 14 programmable timers/counters ................................ ................................ ............... 49 14.1 timer/counters 0 & 1 ................................ ................................ ................................ .... 49 14.2 time - base selection ................................ ................................ ................................ ..... 49 14.2.1 mode 0 ................................ ................................ ................................ ......................... 49 14.2.2 mode 1 ................................ ................................ ................................ ......................... 49 14.2.3 mode 2 ................................ ................................ ................................ ......................... 50 14.2.4 mode 3 ................................ ................................ ................................ ......................... 50 14.3 timer/counter 2 ................................ ................................ ................................ ............ 51 14.3.1 capture mode ................................ ................................ ................................ ............... 51 14.3.2 auto - reload mode, counting up ................................ ................................ .................. 52 14.3.3 auto - reload mode, counting up/down ................................ ................................ ......... 52 14.3.4 baud rate generator mode ................................ ................................ .......................... 53 15 watchdog timer ................................ ................................ ................................ ................. 54 16 serial port ................................ ................................ ................................ ........................... 55 16.1 mode 0 ................................ ................................ ................................ ........................ 56 16.2 mode 1 ................................ ................................ ................................ ........................ 57 16. 3 mode 2 ................................ ................................ ................................ ........................ 58 17 flash rom code boot mode slection ................................ ................................ ........ 61 18 isp (in - system programming) ................................ ................................ ........................ 62 19 config bits ................................ ................................ ................................ ........................... 66 20 electrical characteristics ................................ ................................ ......................... 68 20.1 absolute maximum ratings ................................ ................................ .......................... 68 20.2 dc electrical characteristics ................................ ................................ ...... 69 20.3 ac electrical characteristics ................................ ................................ ....... 70 20.3.1 clo ck input waveform ................................ ................................ ................................ .. 70 20.3.2 program fetch cycle ................................ ................................ ................................ .... 71 20.3.3 data read cycle ................................ ................................ ................................ .......... 71 20.3.4 data write cycle ................................ ................................ ................................ ........... 71 20.3.5 port access cycle ................................ ................................ ................................ ........ 72 20.4 timing waveforms ................................ ................................ ................................ ....... 73 20.4.1 program fetch cycle ................................ ................................ ................................ .... 73 20.4.2 data read cycle ................................ ................................ ................................ .......... 73 20.4.3 data write cycle ................................ ................................ ................................ ........... 74 20.4.4 port access cycle ................................ ................................ ................................ ........ 74 20.4.5 reset pin access cycle ................................ ................................ ............................... 75 21 application circ uits ................................ ................................ ................................ ........ 76 21.1 external program memory and crystal ................................ ................................ ........ 76 21.2 expanded external data memory and oscillator ................................ .......................... 76 21.3 internal program memory and oscillator for eft application ................................ ...... 77 21.4 reference value of xtal ................................ ................................ ............................. 77 22 application note ................................ ................................ ................................ ............... 78
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 3 - revision a1 3 23 package dimensions ................................ ................................ ................................ ......... 83 23.1 40 - pin dip ................................ ................................ ................................ ..................... 83 23.2 44 - pin plcc ................................ ................................ ................................ ................. 84 23.3 44 - pin pqfp ................................ ................................ ................................ ................. 84 23.4 48 - pin lqfp ................................ ................................ ................................ .................. 86 23.5 44 - pin tqfp ................................ ................................ ................................ ................. 87 24 revision history ................................ ................................ ................................ ................ 88
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 4 - revision a1 3 1 general description the w78e054d/w78e052d series is an 8 - bit microcontroller which can accommodate a wid er fr e- quency range with low power consumpti on. the instruction set for the w78e054d/ w78e052d s e ries is fully compati ble with the standard 805 2 . the w78e054d/w78e052d series contains 16k/8k bytes flash eprom programmable by har d ware writer; a 256 bytes ra m; four 8 - bit bi - directional (p0, p1, p2, p3) and bit - addressable i/o ports; an additional 4 - bit i/o port p4; three 16 - bit timer/counters; a hardware watc h dog timer and a serial port. these peripherals are supported by 8 sources 4 - level interrupt capabilit y. to facilitate progra m ming and verificati on, the flash eprom inside the w78e054d/w78e052d series allows the program memory to be programmed and read electronically. once the code is confirmed, the user can pro tect the code for security. the w78e054d/w7 8e052d series microcontroller has two power reduction modes, idle mode and power - down mode, both of which are software selectable. the idle mode turns off the pr o cessor clock but allows for continued peripheral operation. the power - down mode stops the crys tal o s cillator for minimum power consumption. the external clock can be stopped at any time and in any state without affecting the processor. the w78e054d/w78e052d series contains in - system programmable (isp) 2kb ld rom for loader progra m , operating voltage from 3 .3 v to 5.5v. note: if the applied v dd is not stable, especially with long transition time of power on/off, its recommended to apply an external reset ic to the rst pin for improving the stability of sy s- tem.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 5 - revision a1 3 2 features ? fully static de sign 8 - bit c mos microcontroller ? optional 12t or 6t mode ? 12t mode, 12 clocks per machine cycle operation (default) , speed up to 40 mhz /5v ? 6t mode, 6 clocks per machine cycle operation set by the writer , speed up to 20 mhz /5v ? wide supply voltage of 2.4 v to 5.5v ? t e mperature grade is ( - 40 o c~85 o c) ? pin and instruction - set s compatible with mcs - 51 ? 256 bytes of on - chip scratchpad ram ? 16k/8k byte s electrically erasable/programmable flash eprom ? 2k byte s ldrom support isp function (reference application note) ? 64 kb program memory address space ? 64 kb data memory address space ? four 8 - bit bi - directional ports ? 8 - sources, 4 - level interrupt capability ? one extra 4 - bit bit - addressable i/o port, additional / ( available on p qfp, plcc and lqfp package ) ? three 16 - bit timer/counters ? one full duplex serial port ? watchdog timer ? emi reduction mode ? software reset ? built - in power management with idle mode and power down mode ? code protection ? packages: dip40, plcc44, pqf p44, lqfp48 , tqfp44 int2 int3
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 6 - revision a1 3 3 parts information list part no. ram ld rom size ap rom size package temperature grade w78e054ddg 256 bytes 2k bytes 14 k byte s dip - 40 pin - 40 o c~85 o c 0 16k bytes w78e054dpg 2k bytes 14 k byte s plcc - 44 pin - 40 o c~85 o c 0 16k bytes w78e054dfg 2k bytes 14 k byte s pqfp - 44 pin - 40 o c~85 o c 0 16k bytes w78e054d t g 2k bytes 14 k byte s tqfp - 44 pin - 40 o c~85 o c 0 16k bytes w78e054dlg 2k bytes 14 k byte s lqfp - 48 pin - 40 o c~85 o c 0 16k bytes W78E052DDG 2 k byte s 8k byte s dip - 40 pin - 40 o c~85 o c w78e052dpg plcc - 44 pin - 40 o c~85 o c w78e052dfg pqfp - 44 pin - 40 o c~85 o c w78e052d t g tqfp - 44 pin - 40 o c~85 o c w78e052d l g lqfp - 48 pin - 40 o c~85 o c table 3 C 1 : l ad free (rohs) parts inform ation list
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 7 - revision a1 3 4 pin configurations 8 1 8 6 7 1 0 9 1 2 1 1 1 4 1 3 1 6 1 5 1 7 5 4 3 2 1 4 4 4 3 4 2 4 1 4 0 3 8 3 9 3 6 3 7 3 4 3 5 3 2 3 3 3 0 3 1 2 9 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 p 1 . 6 p 1 . 5 r s t p 1 . 7 i n t 2 , p 4 . 3 r x d , p 3 . 0 t x d , p 3 . 1 t 0 , p 3 . 4 t 1 , p 3 . 5 p 1 . 3 p 1 . 2 p 1 . 4 t 2 e x , p 1 . 1 t 2 , p 1 . 0 a d 0 , p 0 . 0 i n t 3 , p 4 . 2 a d 1 , p 0 . 1 a d 2 , p 0 . 2 a d 3 , p 0 . 3 v d d a l e p 0 . 7 , a d 7 p 4 . 1 p 0 . 6 , a d 6 p 0 . 5 , a d 5 p 0 . 4 , a d 4 p 2 . 5 , a 1 3 p 2 . 6 , a 1 4 p 2 . 7 , a 1 5 x t a l 2 x t a l 1 v s s p 2 . 1 , a 9 p 4 . 0 p 2 . 2 , a 1 0 p 2 . 3 , a 1 1 p 2 . 4 , a 1 2 p 2 . 0 , a 8 p l c c 4 4 - p i n i n t 0 , p 3 . 2 p 3 . 7 , r d i n t 1 , p 3 . 3 p s e n e a p 3 . 6 , w r 1 0 9 1 2 1 1 1 4 1 3 1 6 1 5 1 7 p 1 . 6 p 1 . 5 r s t p 1 . 7 r x d , p 3 . 0 t x d , p 3 . 1 t 0 , p 3 . 4 t 1 , p 3 . 5 i n t 0 , p 3 . 2 i n t 1 , p 3 . 3 2 1 4 3 6 5 8 7 p 1 . 3 p 1 . 2 p 1 . 4 t 2 e x , p 1 . 1 t 2 , p 1 . 0 1 9 1 8 2 0 w r , p 3 . 6 r d , p 3 . 7 x t a l 2 x t a l 1 3 8 3 9 3 6 3 7 3 4 3 5 3 2 3 3 3 0 3 1 2 9 2 8 4 0 2 6 2 7 2 4 2 5 2 2 2 3 2 1 p 2 . 1 , a 9 p 2 . 2 , a 1 0 p 2 . 3 , a 1 1 p 2 . 4 , a 1 2 p 2 . 0 , a 8 p 2 . 5 , a 1 3 p 2 . 6 , a 1 4 p 2 . 7 , a 1 5 a l e p 0 . 7 , a d 7 p 0 . 6 , a d 6 p 0 . 5 , a d 5 p 0 . 4 , a d 4 p s e n e a p 0 . 0 , a d 0 p 0 . 1 , a d 1 p 0 . 2 , a d 2 p 0 . 3 , a d 3 v d d d i p 4 0 - p i n v s s
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 8 - revision a1 3 8 1 2 3 7 7 1 0 9 1 1 4 4 4 3 4 2 4 1 4 0 3 9 3 8 3 6 3 5 3 4 3 2 3 3 3 0 3 1 2 8 2 9 2 6 2 7 2 4 2 5 2 3 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 p 1 . 6 p 1 . 5 r s t p 1 . 7 r x d , p 3 . 0 t x d , p 3 . 1 t 0 , p 3 . 4 t 1 , p 3 . 5 p 1 . 3 p 1 . 2 p 1 . 4 t 2 e x , p 1 . 1 t 2 , p 1 . 0 a d 0 , p 0 . 0 a d 1 , p 0 . 1 a d 2 , p 0 . 2 a d 3 , p 0 . 3 v d d a l e p 0 . 7 , a d 7 p 4 . 1 p 0 . 6 , a d 6 p 0 . 5 , a d 5 p 0 . 4 , a d 4 p 2 . 5 , a 1 3 p 2 . 6 , a 1 4 p 2 . 7 , a 1 5 x t a l 2 x t a l 1 v s s p 2 . 1 , a 9 p 4 . 0 p 2 . 2 , a 1 0 p 2 . 3 , a 1 1 p 2 . 0 , a 8 p q f p 4 4 - p i n t q f p 4 4 - p i n i n t 0 , p 3 . 2 p 3 . 7 , r d i n t 1 , p 3 . 3 p s e n e a p 3 . 6 , w r 2 1 4 3 5 6 i n t 2 , p 4 . 3 i n t 3 , p 4 . 2 2 4 4 1 4 3 6 5 8 7 1 0 9 1 1 4 8 4 2 4 1 4 0 3 9 3 8 3 7 3 2 3 3 3 0 3 1 2 8 2 9 2 6 2 7 2 5 1 3 1 4 1 5 1 6 1 8 1 9 2 0 2 1 2 2 p 2 . 7 , a 1 5 p s e n a d 0 , p 0 . 0 a l e e a p 4 . 1 p 0 . 6 , a d 6 p 0 . 5 , a d 5 p 2 . 4 , a 1 2 p 2 . 3 , a 1 1 p 2 . 2 , a 1 0 p 2 . 1 , a 9 x t a l 2 p 3 . 7 , r d p 3 . 6 , w r x t a l 1 i n t 2 , p 4 . 3 i n t 0 , p 3 . 2 i n t 1 , p 3 . 3 t 0 , p 3 . 4 t 1 , p 3 . 5 p 1 . 6 p 1 . 7 r s t a d 2 , p 0 . 3 a d 2 , p 0 . 2 a d 1 , p 0 . 1 p 1 . 3 p 1 . 4 p 1 . 5 p 1 . 2 p 2 . 0 , a 8 p 4 . 0 v s s 1 2 1 7 2 3 2 4 3 4 3 5 3 6 4 6 4 7 4 3 4 5 p 2 . 6 , a 1 4 p 2 . 5 , a 1 3 n c v d d i n t 3 , p 4 . 2 t 2 , p 1 . 0 t 2 e x , p 1 . 1 p 0 . 7 , a d 7 p 0 . 4 , a d 4 p 3 . 1 p 3 . 0 n c n c n c l q f p 4 8 - p i n p 2 . 4 , a 1 2
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 9 - revision a1 3 5 pin descriptions symbol type descriptions i external access enable: this pin forces the processor to execute out of external rom. it shou ld be kept high to access internal rom. the rom address and data will not be present on the bus if pin is high and the program cou n- ter is within internal rom area. otherwise they will be present on the bus. o h pr ogram store enable: enables the external rom data onto the port 0 address/data bus during fetch and movc operations. when internal rom access is performed, no strobe signal outputs from this pin. ale o h address l atch enable: ale is used to enable the address latch that sep a- rates the address from the data on port 0. rst i l reset: a high on this pin for two machine cycles while the oscillator is running resets the device. xtal1 i crystal1: this is the crystal os cillator input. this pin may be driven by an e x- ternal clock. xtal2 o crystal2: this is the crystal oscillator output. it is the inversion of xtal1. vss i ground: ground potential vdd i power supply: supply voltage for operation. p0.0 ? p0.7 i/o d port 0: port 0 is an open - drain bi - directional i/o port. this port also provides a multiplexed low order address/data bus during accesses to external memory. p1.0 ? p1.7 i/o h port 1: port 1 is a bi - directional i/o port with internal pull - ups. the bits have altern ate functions which are described below: t2 (p1.0): timer/counter 2 external count input t2ex (p1.1): timer/counter 2 reload/capture control p2.0 ? p2.7 i/o h port 2: port 2 is a bi - directional i/o port with internal pull - ups. this port also provides the up per address bits for accesses to external memory. ea psen
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 10 - revision a1 3 pin description, continued symbol type descriptions p3.0 ? ? in application if mcu pins need external pull - up, it is recom mended to add a pull - up resistor (10k ? ) between pin and power (v dd ) instead of directly wiring pin to v dd for enhancing emc. int0 int1 wr rd int2 int3
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 11 - revision a1 3 6 block diagram figure 6 C 1 w78e054d/w78e052d block diagram a l u s t a c k p o i n t e r p s w t 1 r e g i s t e r t 2 r e g i s t e r a c c b i n s t r u c t i o n d e c o d e r & s e q u e n c e r b u s & l o c k c o n t r o l l e r d p t r t i m e r r e g . p c i n c r e m e n t o r a d d r . r e g . f l a s h e p r o m p o w e r c o n t r o l s f r & r a m a d d r e s s 2 5 6 b y t e s r a m & s f r t i m e r 0 t i m e r 1 i n t e r r u p t u a r t p o r t 1 l a t c h p o r t 1 p o r t 3 l a t c h p o r t 3 o s c i l l a t o r x t a l 1 x t a l 2 r e s e t b l o c k r s t v c c g n d p 1 . 0 | p 1 . 7 p 3 . 0 | p 3 . 7 o s c i l l a t o r s e l e c t e r p o r t 2 l a t c h p o r t 2 w a t c h d o g t i m e r p o r t 0 l a t c h p o r t 0 p 0 . 0 | p 0 . 7 p 2 . 0 | p 2 . 7 a l e / p s e n p o r t 4 l a t c h p o r t 4 p 4 . 0 | p 4 . 3 t i m e r 2
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 12 - revision a1 3 7 functional descripti on the w78e054d/w78e052d series architecture consists of a core controller surrounded by various registers, five general purpose i/o ports, 16k/8k flash eprom, 2k flash eprom for isp fun c tion, 256 bytes of ram, three timer/counters, and a serial port. the proces sor supports 111 different op - codes and references both a 64k program address space and a 64k data storage space. 7.1 on - chip flash eprom the w78e054d/w78e052d series include one 16k/8k bytes of main flash eprom for application program. 7.2 i/o ports the w78e054 d/w78e052d series has four 8 - bit ports and one extra 4 - bit port. port 0 can be used as an address/data bus when external program is running or external memory/device is a c cessed by movc or movx instruction. in these cases, it has strong pull - ups and pull - d owns, and does not need any external pull - ups. otherwise it can be used as a general i/o port with open - drain circuit. port 2 is used chiefly as the upper 8 - bits of the address bus when port 0 is used as an a d dress/data bus. it also has strong pull - ups and pull - downs when it serves as an address bus. port 1 and 3 act as i/o ports with alternate functions. port 4 is only available on plcc/ p qfp /lqfp package type. it serves as a general purpose i/o port as port 1 and port 3. another bit - addressable bidirectio n a l i/o port p4. p4.3 and p4.2 are alternative function pins. it can be used as general i/o port or exte r nal interrupt input sources ( / ). 7.3 serial i/o the w78e054d/w78e052d series have one serial port that is func tionally similar to the serial port of the original 8032 family. however the serial port on the w78e054d/w78e052d series can ope r ate in different modes in order to obtain timing similarity as well. 7.4 timers timers 0, 1, and 2 each consist of two 8 - bit data registers. these are called tl0 and th0 for timer 0, tl1 and th1 for timer 1, and tl2 and th2 for timer 2. the tcon and tmod registers provide co n- trol functions for timers 0 and 1. the t2con register provides control functions for timer 2. rcap2h and rcap2 l are used as reload/capture registers for timer 2. the operations of timer 0 and timer 1 are the same as in the 8051 cpu. timer 2 is a special feature of the w78e054d/w78e052d : it is a 16 - bit timer/counter that is configured and controlled by the t2con re gister. like timers 0 and 1, timer 2 can operate as either an external event counter or as an internal timer, depending on the setting of bit c/t2 in t2con. timer 2 has three operating modes: capture, auto - reload, and baud rate generator. the clock speed a t capture or auto - reload mode is the same as that of timers 0 and 1. 7.5 interrupts the interrupt structure in the w78e054d/w78e052d is slightly different from that of the standard 8052. due to the presence of additional features and peripherals, the number of interrupt sources and vectors has been increased. the w78e054d/w78e052d provides 8 interrupt resources with four pr i- ority level, including four external interrupt sources, three timer interrupts, serial i/o interrupts. 7.6 data pointers int2 int3
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 13 - revision a1 3 the data pointer of w78e054d/w78e052d series is same as standard 8052 that have one 16 - bit d a- ta pointer (dptr). 7.7 a rchi tecture the w78e054d/w78e052d series are based on the standard 8052 device. it is built around an 8 - bit alu that uses internal registers for temporary stor age and control of the peripheral devices. it can e x- ecute the standard 8052 instruction set. 7.7.1 alu the alu is the heart of the w78e054d/w78e052d series. it is responsible for the arithmetic and log i- cal functions. it is also used in decision making, in case o f jump instructions, and is also used in calc u- lating jump addresses. the user cannot directly use the alu, but the instruction decoder reads the op - code, decodes it, and sequences the data through the alu and its associated registers to generate the requir ed result. the alu mainly uses the acc which is a special function register (sfr) on the chip. another sfr, namely b register is also used multiply and divide instructions. the alu generates several status signals which are stored in the program status wor d register (psw). 7.7.2 accumulator the accumulator (acc) is the primary register used in arithmetic, logical and data transfer oper ations in the w78e054d/w78e052d series. since the accumulator is directly accessible by the cpu, most of the high speed instructio ns make use of the acc as one argument. 7.7.3 b register this is an 8 - bit register that is used as the second argument in the mul and div instructions. for all other instructions it can be used simply as a general purpose register. 7.7.4 program status word this is an 8 - bit sfr that is used to store the status bits of the alu. it holds the carry flag, the auxiliary carry flag, general purpose flags, the register bank select, the overflow flag, and the parity flag. 7.7.5 scratch - pad ram the w78e054d/w78e052d series has a 256 byte on - chip scratch - pad ram. this can be used by the user for temporary storage during program execution. a certain section of this ram is bit addressable, and can be directly addressed for this purpose. 7.7.6 stack pointer the w78e054d/w78e052d series has an 8 - bit stack pointer which points to the top of the stack. this stack resides in t he scratch pad ram in the w78e054d/w78e052d . hence the size of the stack is limited by the size of this ram.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 14 - revision a1 3 8 memory organization the w78e054d/w78e052d series separate the me mory into two separate sections, the program memory and the data memory. the program memory is used to store the instruction op - codes, while the data memory is used to store data or for memory mapped devices. figure 8 C 1 memory map 8.1 program memory (on - chip flash) the program memory on the w78e054d/w78e052d series can be up to 16k/8k bytes (2k bytes for isp f/w , share with the w78e054d ) long. all instructions are fetched for execu tion from this memory area. the movc instruction can also access this memory region. 8.2 scratch - pad ram and register map as mentioned before the w78e054d/w78e052d series have separate program and data memory areas. there are also several special function re gisters (sfrs) which can be accessed by software. the sfrs can be accessed only by direct addressing, while the on - chip ram can be a c cessed by either direct or indirect addressing. indirect addressing ram direct & indirect addressing ram sfrs direct addressing only 00 h 7 fh 80 h ffh 64 k bytes external data memory 14 k / 8 kb aprom ffffh 0000 h 3 fffh 3800 h 2 kb ldrom 0000 h 16 kb aprom 3 fffh 0000 h or
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 15 - revision a1 3 figure 8 C 2 w78e054d/w78e052d ram and sfr memory map since the scratch - pad ram is only 256bytes it can be used only when data contents are small. there are several other special purpose areas within the scratch - pad ram. these are illustrated in next f i g- ure. i n d i r e c t r a m a d d r e s s i n g d i r e c t & i n d i r e c t r a m a d d r e s s i n g s f r d i r e c t a d d r e s s i n g o n l y 0 0 h 7 f h 8 0 h f f h 2 5 6 b y t e s r a m a n d s f r d a t a m e m o r y s p a c e
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 16 - revision a1 3 figure 8 C 3 scratch - pad ram 8.2.1 working registers there are four sets of working registers, each consisting of eight 8 - bit registers. these are termed as banks 0, 1, 2, and 3 . individual registers within these banks can be directly accessed by separate i n- structions. these individual registers are named as r0, r1, r2, r3, r4, r5, r6 an d r7. however, at one time the w78e054d/w78e052d series can work with only one particular bank . the bank sele c- tion is done by setting rs1 - rs0 bits in the psw. the r0 and r1 registers are used to store the a d- dress for indirect accessing. bank 0 bank 1 bank 2 bank 3 03 02 01 00 04 05 06 07 0b 0a 09 08 0c 0d 0e 0f 13 12 11 10 14 15 16 17 1b 1a 19 18 1c 1d 1e 1f 23 22 21 20 24 25 26 27 2b 2a 29 28 2c 2d 2e 2f 33 32 31 30 34 35 36 37 3b 3a 39 38 3c 3d 3e 3f 43 42 41 40 44 45 46 47 4b 4a 49 48 4c 4d 4e 4f 53 52 51 50 54 55 56 57 5b 5a 59 58 5c 5d 5e 5f 63 62 61 60 64 65 66 67 6b 6a 69 68 6c 6d 6e 6f 73 72 71 70 74 75 76 77 7b 7a 79 78 7c 7d 7e 7f direct ram indirect ram 00h 07h 28h 08h 0fh 10h 17h 18h 1fh 20h 21h 22h 23h 24h 25h 26h 27h 29h 2ah 2bh 2ch 2dh 2eh 2fh 30h 7fh 80h ffh
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 17 - revision a1 3 8.2.2 bit addressable locations the scratch - pad ram area from location 20h to 2fh is byte as well as bit addressable. this means that a bit in this area can be individually addressed. in addition some of the sfrs are also bit a d- dressable. the instruction decoder is able to distinguish a bit access from a byte access by the type of the instruction itself. in the sfr area, any existing sfr whose address ends in a 0 or 8 is bit addres s- able. 8.2.3 stack the scratch - pad ram can be used for the stack. this area is selected by the stack pointer (sp), which stores the address of the top of the stack. whenever a jump, call or interrup t is invoked the r e- turn address is placed on the stack. there is no restriction as to where the stack can begin in the ram. by default however, the stack pointer contains 07h at reset. the user can then change this to any value desired. the sp will point t o the last used value. therefore, the sp will be incremented and then address saved onto the stack. conversely, while popping from the stack the contents will be read first, and then the sp is decreased.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 18 - revision a1 3 9 special function reg isters the w78e054d/w78e052d s eries uses special function registers (sfrs) to control and monitor peripherals and their modes. the sfrs reside in the register locations 80 - ffh and are a c cessed by direct addressing only. some of the sfrs are bit addressable. this is very useful in cases where u s- ers wish to modify a particular bit without changing the others. the sfrs that are bit a d dressable are those whos e addresses end in 0 or 8. the w78e054d/w78e052d series contain all the sfrs present in the standard 8052. however some additional sfr s are added. in some cases the unused bits in the original 8052, have been given new functions. the list of the sfrs is as follows. f8 ff f0 b f7 e8 ef e0 acc e7 d8 p4 df d0 psw d7 c8 t2con t2mod rcap2l rca p2h tl2 th2 cf c0 xicon sfral sfrah sfrrd sfrcn c7 b8 ip eapage chpcon bf b0 p3 iph b7 a8 ie af a0 p2 a7 98 scon sbuf 9f 90 p1 97 88 tcon tmod tl0 tl1 th0 th1 auxr wdtc 8f 80 p0 sp dpl dph p 0upr pcon 87 table 9 C 1 : special function register location table note: 1. the sfrs in the column with dark borders are bit - addressable 2. the table is condensed with eight locations per row. empty locations indicate t hat these are no re g- isters at these addresses. when a bit or register is not implemented, it will read high.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 19 - revision a1 3 special function registers: symbol definition address msb bit address, symbol lsb reset b b register f0h (f7) (f6) (f5) (f4) (f3) (f2) (f1) ( f0) 0000 0000b acc accumulator e0h (e7) (e6) (e5) (e4) (e3) (e2) (e1) (e0) 0000 0000b p4 port 4 d8h int2 int3 0000 1111b psw program status word d0h (d7) cy (d6) ac (d5) f0 (d4) rs1 (d3) rs0 (d2) ov (d1) f1 (d0) p 0000 0000b th2 t2 reg. high cdh 0000 0000b tl2 t2 reg. low cch 0000 0000b rcap2h t2 capture low cbh 0000 0000b rcap2l t2 capture high cah 0000 0000b t2mod timer 2 mode c9 dcen 0000 0000b t2con timer 2 control c8h (cf) tf2 (ce) exf2 (cd) rclk ( cc) tclk (cb) exen2 (ca) tr2 (c9) c/t2 (c8) cp/rl2 0000 0000b sfrcn sfr program of control c7h noe nce ctrl3 ctrl2 ctrl1 ctrl0 0000 0000b sfrrd sfr program of data register c6h 0000 0000b sfrah sfr program of address high byte c5h 00 00 0000b sfral sfr program of address low byte c4h 0000 0000b xicon external interrupt control c0h px3 ex3 ie3 it3 px2 ex2 ie2 it2 0000 0000b chpcon chip control bfh swrst - - - - isp enp 0000 0000b eapage erase page operation modes beh eapg1 eapg0 0000 0000b ip interrupt priority b8h (bf) - (be) - (bd) pt2 (bc) ps (bb) pt1 (ba) px1 (b9) pt0 (b8) px0 1100 0000b iph interrupt priority high b7h 0000 0000b p3 port 3 b0h (b7) rd (b6) wr (b5) t1 (b4) t0 (b3) int1 (b2) int0 (b1) txd (b0) rxd 1111 1111b ie interrupt enable a8h (af) ea (ae) - (ad) et2 (ac) es (ab) et1 (aa) ex1 (a9) et0 (a8) ex0 0100 0000b p2 port 2 a0h (a7) a15 (a6) a14 (a5) a13 (a4) a12 (a3) a11 (a2) a10 (a1) a9 (a0) a8 1111 1111b sbuf serial buffer 99h 0000 0000b scon serial control 98h (9f) sm0/fe (9e) sm1 (9d) sm2 (9c) ren (9b) tb8 (9a) rb8 (99) ti (98) ri 0000 0000b p1 port 1 90h (97) (96) (95) (94) (93) (92) (91) t2ex (90) t2 1111 1111b wdtc watchdog control 8fh enw clrw widl - - ps2 ps1 ps0 000 0 0000b auxr auxiliary 8eh - - - - aleoff 0000 0110b th1 timer high 1 8dh 0000 0000b th0 timer high 0 8ch 0000 0000b tl1 timer low 1 8bh 0000 0000b tl0 timer low 0 8ah 0000 0000b tmod timer mode 89h gate c/t m 1 m0 gate c/t m1 m0 0000 0000b tcon timer control 88h (8f) tf1 (8e) tr1 (8d) tf0 (8c) tr0 (8b) ie1 (8a) it1 (89) ie0 (88) it0 0000 0000b pcon power control 87h smod smod0 - por gf1 gf0 pd idl 0011 0000b p 0up r port 0 pull up o ption register 86h - - - - - - - p0up 0000 0001b dph data pointer high 83h 0000 0000b dpl data pointer low 82h 0000 0000b sp stack pointer 81h 0000 0111b p0 port 0 80h (87) (86) (85) (84) (83) (82) (81) (80) 1111 1111b
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 20 - revision a1 3 9.1 sfr detail bit descriptions port 0 bit: 7 6 5 4 3 2 1 0 p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 mnemonic: p0 address: 80h bit name function 7 - 0 p0.[7:0] port 0 is an open - drain bi - directional i/o port if sfr p0upr.0 (bit p0up) clear to 0, and w hen sfr p0up r.0 (bit p0up) set to 1, p ort 0 pins are internally pulled - up. this port also provides a multiplexed low order address/data bus during accesses to external memory. stack pointer bit: 7 6 5 4 3 2 1 0 sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 mnemonic: sp address: 81h bit name fun ction 7 - 0 sp.[7:0] the stack pointer stores the scratch - pad ram address where the stack begins. in other words it always points to the top of the stack. data pointer low bit: 7 6 5 4 3 2 1 0 dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 mnemonic: dp l address: 82h bit name function 7 - 0 dpl.[7:0] this is the low byte of the standard 8052 16 - bit data pointer. data pointer high bit: 7 6 5 4 3 2 1 0 dph.7 dph.6 dph.5 dph.4 dph.3 dph.2 dph.1 dph.0 mnemonic: dph address: 83h bit name function 7 - 0 d ph.[7:0] this is the high byte of the standard 8052 16 - bit data pointer. port 0 pull up option register bit: 7 6 5 4 3 2 1 0 - - - - - - - p0up mnemonic: p0up r address: 86h bit name function 0 p0up 0: port 0 pins are open - drain.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 21 - revision a1 3 1: port 0 pins are internally pulled - up. port 0 is structurally the same as port 2. power control bit: 7 6 5 4 3 2 1 0 smod smod0 - por gf1 gf0 pd idl mnemonic: pcon address: 87h bit name function 7 smod 1: this bit doubles the seria l port baud rate in mode 1, 2, and 3 when set to 1. 6 smod 0 0: framing error detection disable. scon.7 (sm0/fe) bit is used as sm0 (stan d- ard 8052 function). 1: framing error detection enable. scon.7 (sm0/fe) bit is used to reflect as frame error (fe) stat us flag. 5 - reserved 4 por 0: cleared by software. 1: set automatically when a power - on reset has occurred. 3 gf1 general purpose user flags. 2 gf0 general purpose user flags. 1 pd 1: the cpu goes into the power down mode. in this mode, all the clock s are stopped and program execution is frozen. 0 idl 1: the cpu goes into the idle mode. in this mode, the clocks cpu clock stopped, so program execution is frozen. but the clock to the serial, timer and interrupt blocks is not stopped, and these blocks c ontinue operating. timer control bit: 7 6 5 4 3 2 1 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 mnemonic: tcon address: 88h bit name function 7 tf1 timer 1 overflow flag. this bit is set when timer 1 overflows. it is cleared aut o- ma t ically when the program doe s a timer 1 interrupt service routine. software can also set or clear this bit. 6 tr1 timer 1 run control. this bit is set or cleared by software to turn timer/counter on or off. 5 tf0 timer 0 overflow flag. this bit is set when timer 0 overflows. it is cleared aut o- ma t ically when the program does a timer 0 interrupt service routine. software can also set or clear this bit. 4 tr0 timer 0 run control. this bit is set or cleared by software to turn timer/counter on or off. 3 ie1 interrupt 1 edge detect fla g: set by hardware when an edge/level is detected on . this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 2 it1 interrupt 1 type control. set/cleared by software to specify falling edge/ low level triggered external inputs. 1 int
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 22 - revision a1 3 1 ie0 interrupt 0 edge detect flag. set by hardware when an edge/level is detected on . this bit is cleared by hardware when the serv ice routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 0 it0 interrupt 0 type control: set/cleared by software to specify falling edge/ low level triggered external inputs. timer mode control bi t: 7 6 5 4 3 2 1 0 gate m1 m0 gate m1 m0 timer1 timer0 mnemonic: tmod address: 89h bit name function 7 gate gating control: when this bit is set, timer/counter 1 is enabled only while the pin is high and the tr1 control bi t is set. when cleared, the pin has no effect, and timer 1 is enabled whenever tr1 control bit is set. 6 timer or counter select: when clear, timer 1 is incremented by the internal clock. when set, the timer coun ts falling edges on the t1 pin. 5 m1 timer 1 mode select bit 1. see table below. 4 m0 timer 1 mode select bit 0. see table below. 3 gate gating control: when this bit is set, timer/counter 0 is enabled only while the pin is high and the tr0 control bit is set. when cleared, the pin has no e f- fect, and timer 0 is enabled whenever tr0 control bit is set. 2 timer or counter select: when clear, timer 0 is incremented by the internal clock. whe n set, the timer counts falling edges on the t0 pin. 1 m1 timer 0 mode select bit 1. see table below. 0 m0 timer 0 mode select bit 0. see table below. m1, m0: mode select bits: m1 m0 mode 0 0 mode 0: 13 - bit timer/counter tlx serves as 5 - bit pre - scale. 0 1 mode 1: 16 - bit timer/counter, no pre - scale. 1 0 mode 2: 8 - bit timer/counter with auto - reload from thx. 1 1 mode 3: (timer 0) tl0 is an 8 - bit timer/counter controlled by the standard timer0 control bits. th0 is an 8 - bit timer only controlled by timer 1 control bits. (timer 1) timer/counter 1 is stopped. timer 0 lsb bit: 7 6 5 4 3 2 1 0 tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 mnemonic: tl0 address: 8ah bit name function 1 int 0 int t c / t c/ t c/
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 23 - revision a1 3 7 - 0 tl0.[7:0] timer 0 lsb. timer 1 lsb bit: 7 6 5 4 3 2 1 0 tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 mnemonic: tl1 address: 8bh bit name function 7 - 0 tl1.[7:0] timer 1 lsb. timer 0 msb bit: 7 6 5 4 3 2 1 0 th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 mnemonic: th0 address: 8ch bit name function 7 - 0 th0 .[7:0] timer 0 msb. timer 1 msb bit: 7 6 5 4 3 2 1 0 th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 mnemonic: th1 address: 8dh bit name function 7 - 0 th1.[7:0] timer 1 msb. auxr bit: 7 6 5 4 3 2 1 0 - - - - - - - ale_off mnemonic: auxr address : 8eh bit name function 0 ale_off 1: disenable ale output 0: enable ale output watchdog timer control register bit: 7 6 5 4 3 2 1 0 enw clrw widl - - ps2 ps1 ps0 mnemonic: wdtc address: 8fh bit name function 7 enw enable watch - dog if set.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 24 - revision a1 3 6 clr w clear watch - dog timer and p re - scal a r if set. this flag will be cleared automatica l- ly. 5 widl if this bit is set, watch - dog is enabled under idle mode. if cleared, watch - dog is disabled under idle mode. default is cleared. 2 - 0 ps2 - 0 watch - dog p re - scal a r timer select. p re - scal a r is selected when set ps2 ? 0 as fo l- lows: ps2 ps1 ps0 pre - scalar select 0 0 0 2 0 0 1 8 0 1 0 4 0 1 1 16 1 0 0 32 1 0 1 64 1 1 0 128 1 1 1 256 port 1 bit: 7 6 5 4 3 2 1 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 mnemonic: p1 address: 90h bit name function 7 - 0 p1.[7:0] general purpose i/o port. most instructions will read the port p ins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. serial port control bit: 7 6 5 4 3 2 1 0 sm0/fe sm1 sm2 ren tb8 rb8 ti ri mnemonic : scon address: 98h bit name function 7 sm0/fe serial por t mode select bit 0 or framing error flag: the smod0 bit in pcon sfr determines whether this bit acts as sm0 or as fe. the operation of sm0 is described below. when used as fe, this bit will be set to indicate an invalid stop bit. this bit must be manually cleared in software to clear the fe condition. 6 sm1 serial port mode select bit 1. see table below. 5 sm2 multiple processors communication. setting this bit to 1 enables the multiproce s- sor communication feature in mode 2 and 3. in mode 2 or 3, if sm2 is set to 1, then ri will not be activated if the received 9th data bit (rb8) is 0. in mode 1, if sm2 = 1, then ri will not be activated if a valid stop bit was not received. in mode 0, the sm2 bit controls the serial port clock. if set to 0, then the seri al port runs at a divide by 12 clock of the oscillator. this gives compatibility with the standard 8052. when set to 1, the serial clock become divide by 4 of the oscill a-
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 25 - revision a1 3 tor clock. this results in faster synchronous serial communication. 4 ren receive ena ble: 0: disable serial reception. 1: enable serial reception. 3 tb8 this is the 9th bit to be transmitted in modes 2 and 3. this bit is set and cleared by software as desired. 2 rb8 in modes 2 and 3 this is the received 9th data bit. in mode 1, if sm2 = 0, rb8 is the stop bit that was received. in mode 0 it has no function. 1 ti transmit interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the stop bit in all other modes during serial transmission. this bit must be cleared by software. 0 ri receive interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or halfway through the stop bits time in the other modes during serial reception. however the restrictions of sm2 ap ply to this bit. this bit can be cleared only by software. sm1, sm0: mode select bits: mode sm0 sm1 description length baud rate 0 0 0 synchronous 8 tclk divided by 4 or 12 1 0 1 asynchronous 10 variable 2 1 0 asynchronous 11 tclk divided by 32 or 64 3 1 1 asynchronous 11 variable serial data buffer bit: 7 6 5 4 3 2 1 0 sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 mnemonic: sbuf address: 99h bit name function 7~0 sbuf serial data on the serial port is read from or written to this loca tion. it actually consists of two separate internal 8 - bit registers. one is the receive resister, and the other is the transmit buffer. any read access gets data from the receive data buffer, while write access is to the transmit data buffer. port 2 bit: 7 6 5 4 3 2 1 0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 mnemonic: p2 address: a0h bit name function 7 - 0 p2.[7:0] port 2 is a bi - directional i/o port with internal pull - ups. this port also provides the upper address bits for accesses to external memory .
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 26 - revision a1 3 interrupt enable bit: 7 6 5 4 3 2 1 0 ea - et2 es et1 ex1 et0 ex0 mnemonic: ie address: a8h bit name function 7 ea global enable. enable/disable all interrupts. 6 - reserved 5 et2 enable timer 2 interrupt. 4 es enable serial port 0 interrupt. 3 et1 enable timer 1 interrupt. 2 ex1 enable external interrupt 1. 1 et0 enable timer 0 interrupt. 0 ex0 enable external interrupt 0. port 3 bit: 7 6 5 4 3 2 1 0 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 mnemonic: p3 address: b0h p3.7 - 0: general purp ose input/output port. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. these alte r- nate functions are described below: bit name function 7 p3.7 6 p3.6 5 p3.5 t1 4 p3.4 t0 3 p3.3 2 p3.2 1 p3.1 tx 0 p3.0 rx interrupt high priority bit: 7 6 5 4 3 2 1 0 iph . 7 iph . 6 iph . 5 iph . 4 iph . 3 iph . 2 iph . 1 iph . 0 mnemonic: iph address: b7h bi t name function 7 iph . 7 1: i nterrupt high priority of int3 is highest priority level. rd wr int1 int0
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 27 - revision a1 3 6 iph . 6 1: i nterrupt high priority of int2 is highest priority level. 5 iph . 5 1: i nterrupt high priority of timer 2 is highest priority level. 4 iph . 4 1: i nterrupt hi gh priority of serial p ort 0 is highest priority level. 3 iph . 3 1: i nterrupt high priority of timer 1 is highest priority level. 2 iph . 2 1: i nterrupt high priority of external interrupt 1 is highest priority level. 1 iph . 1 1: i nterrupt high priority of timer 0 is highest priority level. 0 iph . 0 1: i nterrupt high priority of external interrupt 0 is highest priority level. interrupt priority bit: 7 6 5 4 3 2 1 0 - - pt2 ps pt1 px1 pt0 px0 mnemonic: ip address: b8h bit name function 5 pt2 1: i nterrup t priority of timer 2 is higher priority level. 4 ps 1: i nterrupt priority of serial port 0 is higher priority level. 3 pt1 1: i nterrupt priority of timer 1 is higher priority level. 2 px1 1: i nterrupt priority of external interrupt 1 is higher priority level. 1 pt0 1: i nterrupt priority of timer 0 is higher priority level. 0 px0 1: i nterrupt priority of external interrupt 0 is higher priority level. eapage erase page operation modes bit: 7 6 5 4 3 2 1 0 - - - - - - eapg1 eapg0 mnemonic: eapage address: bd bit name function 1 eapg1 1 : to ease page1 when ease command is set. ( ld rom ) 0 eapg0 1 : to ease page0 when ease command is set. (ap rom ) ;cpu clock = 12mhz/12t mode read_time e qu 1 program_time equ 50 erase_time equ 5000 erase_ ap rom : mov eapage,#01h ;set eapage is aprom mov sfrcn,#erase_rom mov tl0,#low (65536 - erase_time) mov th0,#high(65536 - erase_time) set b tr0
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 28 - revision a1 3 mov chpcon,#00000011b mov eapage,#00h ;clear eapage clr tf0 clr tr0 ret erase_ ld rom : mov eapage,#0 2 h ;set eapage is ld rom mov sfrcn,#erase_rom mov tl0,#low (65536 - era se_time) mov th0,#high(65536 - erase_time) setb tr0 mov chpcon,#00000011b mov eapage,#00h ;clear eapage clr tf0 clr tr0 ret chip control bit: 7 6 5 4 3 2 1 0 swrst - - - - - isp enp mnemonic : chpcon address: bfh bit name function 7 swrst when this bit is set to 1 and enp is set to 1. it will enforce microcontroller reset to initial condition just like power on reset. this action will re - boot the microcontroller and start to normal operation. 1 isp the isp function select. when this bit is set to 1 and enp is set to 1. it will run isp function . 0 enp when this bit is set to 1 and swrst is set to 1. it will enforce microcontro l- ler rese t to initial condition just like power on reset. when this bit is set to 1 and isp is set to 1. it will run isp function note 1: chpcon = 0x81, it is software reset note2: chpcon = 0x03, isp function is enabled. external interrupt control bit: 7 6 5 4 3 2 1 0 px3 ex3 ie3 it3 px2 ex2 ie2 it2 mnemonic: xicon address: c0h bit name function 7 px3 external interrupt 3 priority is high er if set this bit to 1 6 ex3 e nable external interrupt 3 if set this bit to 1
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 29 - revision a1 3 5 ie3 if it3 = 1, ie3 is set/cleared automat ically by hardware when interrupt is detec t- ed/serviced 4 it3 external interrupt 3 is falling - edge/low - level triggered when this bit is set/cleared by software 3 px2 external interrupt 2 priority is high er if set this to 1 2 ex2 e nable external interrupt 2 if set this bit to 1 1 ie2 if it2 = 1, ie2 is set/cleared automatically by hardware when interrupt is detec t- ed/serviced 0 it2 external interrupt 2 is falling - edge/low - level triggered when this bit is set/cleared by software sfr program of address lo w bit: 7 6 5 4 3 2 1 0 sfral.7 sfral.6 sfral.5 sfral.4 sfral.3 sfral.2 sfral.1 sfral.0 mnemonic: sfral address: c4h bit name function 7 - 0 sfral.[7:0] the programming address of on - chip flash memory in programming mode. sfrfal contains the low - order byt e of address. sfr program of address high bit: 7 6 5 4 3 2 1 0 sfrah.7 sfrah.6 sfrah.5 sfrah.4 sfrah.3 sfrah.2 sfrah.1 sfrah.0 mnemonic: sfrah address: c5h bit name function 7 - 0 sfrah.[7:0] the programming address of on - chip flash memory in programmi ng mode. sfrfah contains the high - order byte of address. sfr program for data bit: 7 6 5 4 3 2 1 0 sfrfd.7 sfrfd.6 sfrfd.5 sfrfd.4 sfrfd.3 sfrfd.2 sfrfd.1 sfrfd.0 mnemonic: sfrfd address: c6h bit name function 7 - 0 sfrfd.[7:0] the programming data for on - chip flash memory in programming mode. sfr for program control bit: 7 6 5 4 3 2 1 0 - oen cen ctrl3 ctrl2 ctrl1 ctrl0 mnemonic: sfrcn address: c7h bit name function
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 30 - revision a1 3 5 oen flash eprom output enable. 4 cen flash epro m chip enable. 3 - 0 ctrl[3:0] ctrl[3:0]: the flash control signals mode oen cen ctrl<3:0> sfrah, sfral sfrfd flash standby 1 1 x x x read company id 0 0 1 01 1 0ffh, 0ffh data out read device id high 0 0 11 00 0ffh, 0ffh data out read device id low 1 0 11 00 0ffh, 0feh data out eras e aprom 1 0 0010 x x erase verify aprom 0 0 1 001 address in data out program aprom 1 0 0001 address in data in program verify aprom 0 0 1 01 0 address in data out read aprom 0 0 0000 address in data out timer 2 control bit: 7 6 5 4 3 2 1 0 tf2 exf 2 rclk tclk exen2 tr2 mnemonic: t2con address: c8h bit name function 7 tf2 timer 2 overflow flag: this bit is set when timer 2 overflows. it is also set when the count is equal to the capture register in down count mod e. it can be set only if rclk and tclk are both 0. it is cleared only by software. software can also set or clear this bit. 6 exf2 timer 2 external flag: a negative transition on the t2ex pin (p1.1) or timer 2 overflow will cause this flag to set based on the , exen2 and dcen bits. if set by a negative transition, this flag must be cleared by software. se t- ting this bit in software or detection of a negative transition on t2ex pin will force a timer interrupt if enabled. 5 rclk receive clo ck flag: this bit determines the serial port 0 time - base when r e- ceiving data in serial modes 1 or 3. if it is 0, then timer 1 overflow is used for baud rate generation, otherwise timer 2 overflow is used. setting this bit forces timer 2 in baud rate genera tor mode. 4 tclk transmit clock flag: this bit determines the serial port 0 time - base when transmitting data in modes 1 and 3. if it is set to 0, the timer 1 overflow is used to generate the baud rate clock otherwise timer 2 overflow is used. setting this bit forces timer 2 in baud rate generator mode. 3 exen2 timer 2 external enable. this bit enables the capture/reload function on the t2ex pin if timer 2 is not generating baud clocks for the serial port. if this bit is 0, then the t2ex pin will be ignore d, otherwise a negative transition detec t- ed on the t2ex pin will result in capture or reload. c t / 2 cp rl / 2 cp rl / 2
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 31 - revision a1 3 2 tr2 timer 2 run control. this bit enables/disables the operation of timer 2. clea r- ing this bit will halt the timer 2 and preserve the current count in th2, tl 2. 1 counter/timer select. this bit determines whether timer 2 will function as a timer or a counter. independent of this bit, the timer will run at 2 clocks per tick when used in baud rate generator mode. 0 capture/re load select. this bit determines whether the capture or reload function will be used for timer 2. if either rclk or tclk is set, this bit will be ignored and the timer will function in an auto - reload mode following each ove r- flow. if the bit is 0 then auto - reload will occur when timer 2 overflows or a fal l- ing edge is detected on t2ex pin if exen2 = 1. if this bit is 1, then timer 2 captures will occur when a falling edge is detected on t2ex pin if exen2 = 1. timer 2 mode control bit: 7 6 5 4 3 2 1 0 - - - - - - dcen mnemonic: t2mod address: c9h bit name function 0 dcen down count enable: this bit, in conjunction with the t2ex pin, controls the direction that timer 2 counts in 16 - bit auto - reload mode. timer 2 capture lsb bit: 7 6 5 4 3 2 1 0 rcap2l.7 rcap2l.6 rcap2l.5 rcap2l.4 rcap2l.3 rcap2l.2 rcap2l.1 rcap2l.0 mnemonic: rcap2l address: cah bit name function 7 - 0 rcap2l.[7:0] this register is used to capture the tl2 value when a timer 2 is configured in capture mode. rcap2l is also used as the lsb o f a 16 - bit reload value when timer 2 is configured in auto - reload mode. timer 2 capture msb bit: 7 6 5 4 3 2 1 0 rcap2h.7 rcap2h.6 rcap2h.5 rcap2h.4 rcap2h.3 rcap2h.2 rcap2h.1 rcap2h.0 mnemonic: rcap2h address: cbh bit name function 7 - 0 rcap2h.[7:0] this register is used to capture the th2 value when a timer 2 is configured in capture mode. rcap2h is also used as the msb of a 16 - bit reload value when timer 2 is configured in auto - reload mode. timer 2 lsb bit: 7 6 5 4 3 2 1 0 c t / 2 cp rl / 2
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 32 - revision a1 3 tl2.7 tl2.6 tl2.5 tl2. 4 tl2.3 tl2.2 tl2.1 tl2.0 mnemonic: tl2 address: cch bit name function 7 - 0 tl2.[7:0] timer 2 lsb timer 2 msb bit: 7 6 5 4 3 2 1 0 th2.7 th2.6 th2.5 th2.4 th2.3 th2.2 th2.1 th2.0 mnemonic: th2 address: cdh bit name function 7 - 0 th2.[7:0] timer 2 msb program status word bit: 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p mnemonic: psw address: d0h bit name function 7 cy carry flag: set for an arithmetic operation which results in a carry being generated from the alu. it is also used as the accumulator for the bit operations. 6 ac auxiliary carry: set when the previous operation resulted in a carry from the high order nibble. 5 f0 user flag 0: the general purpose flag that can be set or cleared by the user. 4 rs1 register bank select bits: 3 rs0 re gister bank select bits: 2 ov overflow flag: set when a carry was generated from the seventh bit but not from the 8 th bit as a result of the previous operation, or vice - versa. 1 f1 user flag 1: the general purpose flag that can be set or cleared by the u ser by software. 0 p parity flag: set/cleared by hardware to indicate odd/even number of 1s in the accumulator. port 4 bit: 7 6 5 4 3 2 1 0 - - - - p4.3 p4.2 p4.1 p4.0 mnemonic: p4 address: d8h another bit - addressable port p4 is also available and on ly 4 bits (p4<3:0>) can be used. this port a d- dress is located at 0d8h with the same function as that of port p1, except the p4.3 and p4.2 are alte r- native function pins. it can be used as general i/o pins or external interrupt input sources ( , int2
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 33 - revision a1 3 ). accumulator bit: 7 6 5 4 3 2 1 0 acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 mnemonic: acc address: e0h bit name function 7 - 0 acc the a or acc register is the standard 8052 accumulator. b register bit: 7 6 5 4 3 2 1 0 b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 mnemonic: b address: f0h bit name function 7 - 0 b the b register is the standard 8052 register that serves as a second accumulator. int3
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 34 - revision a1 3 10 instruction the w78e054d/w78e052d series execute all the instructions of the sta ndard 8052 family. the oper a- tions of these instructions, as well as their effects on flag and status bits, are exactly the same. op - code hex code bytes w78e054d/w78e052d series clock cycles nop 00 1 12 add a, r0 28 1 12 add a, r1 29 1 12 add a, r2 2a 1 12 add a, r3 2b 1 12 add a, r4 2c 1 12 add a, r5 2d 1 12 add a, r6 2e 1 12 add a, r7 2f 1 12 add a, @r0 26 1 12 add a, @r1 27 1 12 add a, direct 25 2 12 add a, #data 24 2 12 addc a, r0 38 1 12 addc a, r1 39 1 12 addc a, r2 3a 1 12 addc a, r3 3b 1 12 addc a, r4 3c 1 12 addc a, r5 3d 1 12 addc a, r6 3e 1 12 addc a, r7 3f 1 12 addc a, @r0 36 1 12 addc a, @r1 37 1 12 addc a, direct 35 2 12 addc a, #data 34 2 12 subb a, r0 98 1 12 subb a, r1 99 1 12 subb a, r2 9a 1 12 subb a, r3 9b 1 1 2 subb a, r4 9c 1 12 subb a, r5 9d 1 12
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 35 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles subb a, r6 9e 1 12 subb a, r7 9f 1 12 subb a, @r0 96 1 12 subb a, @r1 97 1 12 subb a, direct 95 2 12 subb a, #data 94 2 12 inc a 04 1 12 inc r0 08 1 12 inc r1 09 1 12 inc r2 0a 1 12 inc r3 0b 1 12 inc r 4 0c 1 12 inc r5 0d 1 12 inc r6 0e 1 12 inc r7 0f 1 12 inc @r0 06 1 12 inc @r1 07 1 12 inc direct 05 2 12 inc dptr a3 1 24 dec a 14 1 12 dec r0 18 1 12 dec r1 19 1 12 dec r2 1a 1 12 dec r3 1b 1 12 dec r4 1c 1 12 dec r5 1d 1 12 dec r6 1e 1 12 dec r7 1f 1 12 dec @r0 16 1 12 dec @r1 17 1 12 dec direct 15 2 12 mul ab a4 1 48 div ab 84 1 48 da a d4 1 12
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 36 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles anl a, r0 58 1 12 anl a, r1 59 1 12 anl a, r2 5a 1 12 anl a, r3 5b 1 12 anl a, r4 5c 1 12 anl a, r5 5d 1 12 anl a, r6 5e 1 12 anl a , r7 5f 1 12 anl a, @r0 56 1 12 anl a, @r1 57 1 12 anl a, direct 55 2 12 anl a, #data 54 2 12 anl direct, a 52 2 12 anl direct, #data 53 3 24 orl a, r0 48 1 12 orl a, r1 49 1 12 orl a, r2 4a 1 12 orl a, r3 4b 1 12 orl a, r4 4c 1 12 orl a, r5 4d 1 12 orl a, r6 4e 1 12 orl a, r7 4f 1 12 orl a, @r0 46 1 12 orl a, @r1 47 1 12 orl a, direct 45 2 12 orl a, #data 44 2 12 orl direct, a 42 2 12 orl direct, #data 43 3 24 xrl a, r0 68 1 12 xrl a, r1 69 1 12 xrl a, r2 6a 1 12 xrl a, r3 6b 1 12 xrl a, r4 6c 1 12 xrl a, r5 6d 1 12
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 37 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles xrl a, r6 6e 1 12 xrl a, r7 6f 1 12 xrl a, @r0 66 1 12 xrl a, @r1 67 1 12 xrl a, direct 65 2 12 xrl a, #data 64 2 12 xrl direct, a 62 2 12 xrl direct, #data 63 3 24 clr a e4 1 12 cpl a f4 1 12 rl a 23 1 12 r lc a 33 1 12 rr a 03 1 12 rrc a 13 1 12 swap a c4 1 12 mov a, r0 e8 1 12 mov a, r1 e9 1 12 mov a, r2 ea 1 12 mov a, r3 eb 1 12 mov a, r4 ec 1 12 mov a, r5 ed 1 12 mov a, r6 ee 1 12 mov a, r7 ef 1 12 mov a, @r0 e6 1 12 mov a, @r1 e7 1 12 mov a , direct e5 2 12 mov a, #data 74 2 12 mov r0, a f8 1 12 mov r1, a f9 1 12 mov r2, a fa 1 12 mov r3, a fb 1 12 mov r4, a fc 1 12 mov r5, a fd 1 12 mov r6, a fe 1 12
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 38 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles mov r7, a ff 1 12 mov r0, direct a8 2 24 mov r1, direct a9 2 24 mov r2, direct a a 2 24 mov r3, direct ab 2 24 mov r4, direct ac 2 24 mov r5, direct ad 2 24 mov r6, direct ae 2 24 mov r7, direct af 2 24 mov r0, #data 78 2 12 mov r1, #data 79 2 12 mov r2, #data 7a 2 12 mov r3, #data 7b 2 12 mov r4, #data 7c 2 12 mov r5, #data 7d 2 12 mov r6, #data 7e 2 12 mov r7, #data 7f 2 12 mov @r0, a f6 1 12 mov @r1, a f7 1 12 mov @r0, direct a6 2 24 mov @r1, direct a7 2 24 mov @r0, #data 76 2 12 mov @r1, #data 77 2 12 mov direct, a f5 2 12 mov direct, r0 88 2 24 mov direct, r1 89 2 24 mov direct, r2 8a 2 24 mov direct, r3 8b 2 24 mov direct, r4 8c 2 24 mov direct, r5 8d 2 24 mov direct, r6 8e 2 24 mov direct, r7 8f 2 24 mov direct, @r0 86 2 24 mov direct, @r1 87 2 24
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 39 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles mov direct, direct 85 3 24 mov direct, #data 75 3 24 mov dptr, #data 16 90 3 24 movc a, @a+dptr 93 1 24 movc a, @a+pc 83 1 24 movx a, @r0 e2 1 24 movx a, @r1 e3 1 24 movx a, @dptr e0 1 24 movx @r0, a f2 1 24 movx @r1, a f3 1 24 movx @dptr, a f0 1 24 push direct c0 2 24 pop direct d0 2 24 xch a, r0 c8 1 12 xch a, r1 c9 1 12 xch a, r2 ca 1 12 xch a, r3 cb 1 12 xch a, r4 cc 1 12 xch a, r5 cd 1 12 xch a, r6 ce 1 12 xch a, r7 cf 1 12 xch a, @r0 c6 1 12 xch a, @r1 c7 1 12 xchd a, @r0 d6 1 12 xchd a, @r1 d7 1 12 xch a, direct c5 2 24 clr c c3 1 12 clr bit c2 2 12 setb c d3 1 12 setb bit d2 2 12 cpl c b3 1 12 cpl bit b2 2 12 anl c, bit 82 2 24 anl c, /bit b0 2 24
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 40 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles orl c, bit 72 2 24 orl c, /bit a0 2 24 mov c, bit a2 2 12 mov bit, c 92 2 24 acall addr11 71, 91, b1, 11, 31, 51, d1, f 1 2 24 lcall addr16 12 3 24 ret 22 1 24 reti 32 1 24 ajmp addr11 01, 21, 41, 61, 81, a1, c1, e1 2 24 ljmp addr16 02 3 24 jmp @a+dptr 73 1 24 sjmp rel 80 2 24 jz rel 60 2 24 jnz rel 70 2 24 jc rel 40 2 24 jnc rel 50 2 24 jb bit, rel 20 3 24 jnb bit, rel 30 3 24 jbc bit, rel 10 3 24 cjne a, direct, rel b5 3 24 cjne a, #data, rel b4 3 24 cjne @r0, #data, rel b6 3 24 cjne @r1, #data, rel b7 3 24 cjne r0, #data, rel b8 3 24 cjne r1, #data, rel b9 3 24 cjne r2, #data, rel ba 3 24 cjne r3, #d ata, rel bb 3 24 cjne r4, #data, rel bc 3 24 cjne r5, #data, rel bd 3 24 cjne r6, #data, rel be 3 24 cjne r7, #data, rel bf 3 24
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 41 - revision a1 3 op - code hex code bytes w78e054d/w78e052d series clock cycles djnz r0, rel d8 2 24 djnz r1, rel d9 2 24 djnz r5, rel dd 2 24 djnz r2, rel da 2 24 djnz r3, rel db 2 24 djnz r4, rel dc 2 24 djnz r6, rel de 2 24 djnz r7, rel df 2 24 djnz direct, rel d5 3 24 table 10 - 1 : instruction set for w78e054d/w78e052d
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 42 - revision a1 3 10.1 instruction timing a machine cycle consists of a sequence of 6 states, number ed s1 through s6. each state time lasts for two oscillator periods. thus a machine cycle t akes 12 oscillator periods or 1 u s if the oscillator fr e- quency is 12mhz. each state is divided into a phase 1 half and a phase 2 half. the fetch/execute sequences in s tates and phases for various kinds of instructions. normally two program fetches are generated during each machine cycle, even if the instruction being executed doesnt require it. if the instruction being execu t- ed doesnt need more code bytes, the cpu sim ply ignores the extra fetch, and the program counter is not incremented. execution of a one - cycle instruction begins during state 1 of the machine cycle, when the opcode is latched into the instruction register. a second fetch occurs during s4 of the same machine cycle. execution is complete at the end of state 6 of this machine cycle. the movx instructions take two machine cycles to execute. no program fetch is generated during the second cycle of a movx instruction. this is the only time program fetches a re skipped. the fetch/execute sequence for movx instructions. the fetch/execute sequences are the same whether the program memory is internal or external to the chip. execution times do not depend on whether the program memory is internal or external. t he signals and timing involved in program fetches when the program memory is external. if program memory is external, then the program memory read strobe psen is normally activated twice per m a- chine cycle. if an access to external data memory occurs, two psen pulse are skipped, because the address and data bus are being used for the data memory access. note that a data memory bus c y- cle takes twice as much time as a program memory bus cycle.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 43 - revision a1 3 11 power management the w78e054d/w78e052d has several features that hel p the user to control the power consumption of the device. the power saved features have basically the power down mode and the idle mode of operation. 11.1 idle mode the user can put the device into idle mode by writing 1 to the bit pcon.0. the instruction tha t sets the idle bit is the last instruction that will be executed before the device goes into idle mode. in the idle mode, the clock to the cpu is halted, but not to the interrupt, timer, watchdog timer and serial port blocks. this forces the cpu state to be frozen; the program counter, the stack pointer, the program status word, the accumulator and the other registers hold their contents. the port pins hold the log i- cal states they had at the time idle was activated. the idle mode can be terminated in two w ays. since the interrupt controller is still active, the activation of any enabled interrupt can wake up the processor. this will automatically clear the idle bit, terminate the idle mode, and the interrupt service ro u tine (isr) will be executed. after the isr, execution of the program will continue from the instruction which put the device into idle mode. the idle mode can also be exited by activating the reset. the device can put int o reset either by appl y- ing a high on the external rst pin, a power on re set condition or a watchdog timer reset. the exte r- nal reset pin has to be held high for at least two ma chine cycles i.e. 24 clock periods to be recognized as a valid reset. in the reset condition the program counter is reset to 0000h and all the sfrs are s et to the reset condition. since the clock is already running there is no delay and execution starts imm e- diately. 11.2 power down mode the device can be put into power down mode by writing 1 to bit pcon.1. the instruction that does this will be the last instr uction to be executed before the device goes into power down mode. in the power down mode, all the clocks are stopped and the device comes to a halt. all activity is completely stopped and the power consumption is reduced to the lowest possible value. the port pins output the values held by their respective sfrs. the w78e054d/w78e052d will exit the power down mode with a reset or by an external interrupt pin enabled as level detect s . an external reset can be used to ex it the power down state. the high on r st pin terminates the power down mode, and restarts the clock. the program execution will restart from 0000h. in the power down mode, the clock is stopped, so the watchdog timer cannot be used to provide the reset to exit power down mode. the w78e054d/w78 e052d can be woken from the power down mode by forcing an external inte r- rupt pin activated, provided the corresponding interrupt is enabled, while the global en a ble(ea) bit is set and the external input has been set to a level detect mode. if these conditi ons are met, then the high level on the external pin re - starts the oscillator. then device executes the interrupt service routine for the corresponding external interrupt. after the interrupt service routine is completed, the program execution returns to t he instruction after one which put the device into power down mode and conti n- ues from there.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 44 - revision a1 3 12 reset conditions the user has several hardware related options for placing the w78e054d/w78e052d into reset co n- d i tion. in general, most register bits go to their reset value irrespective of the reset condition, but there are a few flags whose state depends on the source of reset. the user can use these flags to dete r- mine the cause of reset using software. 12.1 sources of reset 12.1.1 external reset the device continuously sa mples the rst pin at state s5p2 of every machine cycle. therefore the rst pin must be held for at least 2 machine cycles (24 clock cycles) to ens ure detection of a valid rst high . the reset circuitry then synchronously applies the internal reset signal. th us the reset is a synchronous operation and requires the clock to be running to cause an external reset. for more ti m- ing information, please reference the character 21.4.5 (page 7 7 ). once the device is in reset condition, it wi ll remain so as long as rst is 1 . even after rst is dea c- tivated, the device will continue to be in reset state for up to two machine cycles, and then begin pr o- gram execution from 0000h. there is no flag associated with the external reset condition. 12.1.2 software reset the w78e054d/w78e05 2d offers a software reset to switch back to the ap rom . se t ting chpcon bits 0 , 1 and 7 to logic - 1 creates software reset to reset the cpu to start aprom code . note: software reset only ldrom jump to aprom, aprom cant software reset to ldrom. 12.1.3 watchdog tim er reset the watchdog timer is a free running timer with programmable time - out intervals. the user can clear the watchdog timer at any time, causing it to restart the count. when the time - out interval is reached an interrupt flag is set. if the watchdog re set is enabled and the watchdog timer is not cleared, the watch dog timer will generate a reset . this places the device into the reset condition. the reset cond i- tion is maintained by hardware for two machine cycles. once the reset is removed the device will begin execution from 0000h. 12.2 r eset s tate most of the sfrs and registers on the device will go to the same condition in the reset state. the pr o- gram counter is forced to 0000h and is held there as long as the reset condition is applied. however, the reset state does not affect the on - chip ram. the data in the ram will be preserved during the r e- set. however, the stack pointer is reset to 07h, and therefore the stack contents will be lost. the ram contents will be lost if the vdd falls below approximately 2v, as this is the minimum voltage level r e- quired for the ram to operate normally. therefore after a first time power on reset the ram contents will be indeterminate. during a power fail condition, if the power falls below 2v, the ram contents are lost. after a reset most sfrs are cleared. interrupts and timers are disabled. the watchdog timer is dis a- bled if the reset source was a por. the port sfrs ha s 0 ffh written into them which puts the port pins in a high state.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 45 - revision a1 3 13 interrupts the w78e054d/w78e052d has a 4 p riority level interrupt structure with 8 interrupt sources. each of the interrupt sources has an individual priority bit, flag, interrupt vector and enable bit. in addition, the interrupts can be globally enabled or disabled. 13.1 interrupt sources the extern al interrupts and can be either edge triggered or level triggered, depending on bits it0 and it1. the bits ie0 and ie1 in the tcon register are the flags which are checked to gene r- ate the interrupt. in the edge tri ggered mode, the intx inputs are sampled in every machine cycle. if the sample is high in one cycle and low in the next, then a high to low transition is detected and the interrupts request flag iex in tcon o is set. the flag bit requests the interrupt. si nce the external i n- terrupts are sampled every machine cycle, they have to be held high or low for at least one complete machine cycle. the iex flag is automatically cleared when the service routine is called. if the level tri g- gered mode is selected, then t he requesting source has to hold the pin low till the interrupt is serviced. the iex flag will not be cleared by the hardware on entering the service routine. if the interrupt conti n- ues to be held low even after the service routine is completed, then the p rocessor may acknowledge another interrupt request from the same source. note that the external interrupts and . by default, the individual interrupt flag corresponding to external interrupt 2 to 3 must be cleared m anually by software. the timer 0 and 1 interrupts are generated by the tf0 and tf1 flags. these flags are set by the ove r- flow in the timer 0 and timer 1. the tf0 and tf1 flags are automatically cleared by the hardware when the timer interrupt is serviced. the timer 2 interrupt is generated by a logical or of the tf2 and the exf2 flags. these flags are set by overflow or capture/reload events in the timer 2 operation. the hardware does not clear these flags when a timer 2 interrupt is executed. software has to resolve the cause of the interrupt between tf2 and exf2 and clear the appropriate flag. the serial block can generate interrupts on reception or transmission. there are two interrupt sources from the serial block, which are obtained by the ri and ti bi ts in the scon sfr, these bits are not automatically cleared by the hardware, and the user will have to clear these bits using software. all the bits that generate interrupts can be set or reset by hardware, and thereby software initiated i n- terrupts can be generated. each of the individual interrupts can be enabled or disabled by setting or clearing a bit in the ie sfr. ie also has a global enable/disable bit ea, which can be cleared to dis a- ble all the interrupts, at once. source vector address source vect or address external interrupt 0 0003h timer 0 overflow 000bh external interrupt 1 0013h timer 1 overflow 001bh serial port 0023h timer 2 overflow 002bh external interrupt 2 0033h external interrupt 3 003bh table 13 C 1 w78e054d/w78e052d interrupt vector table 13.2 priority level structure there are 4 priority levels for the interrupts high, low. naturally, a higher priority interrupt cannot be interrupted by a lower priority interrupt. however there exists a p re - defined hierarchy amongst the i n- terrupts themselves. this hierarchy comes into play when the interrupt controller has to resolve simu l- taneous requests having the same priority level. this hierarchy is defined as shown on table. int 0 int 1 int2 int3
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 46 - revision a1 3 priority bits interrupt p riority level iph ip/ xicon.7/ xicon.3 0 0 level 0 (lowest priority) 0 1 level 1 1 0 level 2 1 1 level 3 (highest priority) the interrupt flags are sampled every machine cycle. in the same machine cycle, the sampled inte r- rupts are polled and their priority is resolved. if certain conditions are met then the hardware will ex e- cute an internally generated lcall instruction which will vector the process to the appropriate inte r- rupt vector address. the conditions for generating the lcall are; 1. an inter rupt of equal or higher priority is not currently being serviced. 2. the current polling cycle is the last machine cycle of the instruction currently being executed. 3. the current instruction does not involve a write to ie, ip, iph, xicon registers and is not a reti. if any of these conditions are not met, then the lcall will not be generated. the polling cycle is r e- peated every machine cycle, with the interrupts sampled in the same machine cycle. if an interrupt flag is active in one cycle but not respon ded to, and is not active when the above conditions are met, the denied interrupt will not be serviced. this means that active interrupts are not remembered; every pol l- ing cycle is new. the processor responds to a valid interrupt by executing an lcall ins truction to the appropriate se r- vice routine. this may or may not clear the flag which caused the interrupt. in case of timer interrupts, the tf0 or tf1 flags are cleared by hardware whenever the processor vectors to the appropriate timer service routine. i n case of external interrupt, /int0 and /int1, the flags are cleared only if they are edge triggered. in case of serial interrupts, the flags are not cleared by hardware. in the case of timer 2 interrupt, the flags are not cleared by hardware. the hardware lcall behaves exactly like the sof t- ware lcall instruction. this instruction saves the program counter contents onto the stack, but does not save the program status word psw. the pc is reloaded with the vector address of that interrupt which caused the lca ll. these address of vector for the different s ources are as shown on the below t able . the vector table is not evenly spaced; this is to accommodate future expansions to the device family. execution continues from the vectored address till an reti instruc tion is executed. on execution of the reti instruction the processor pops the stack and loads the pc with the contents at the top of the stack. the user must take care that the status of the stack is restored to what is after the har d ware lcall, if the exe cution is to return to the interrupted program. the processor does not notice anything if the stack contents are modified and will proceed with execution from the address put back into pc. note that a ret instruction would perform exactly the same process as a reti instruction, but it would not inform the interrupt controller that the interrupt service routine is completed, and would leave the controller still thinking that the service routine is underway. each interrupt source can be individually enabled or disabled by setting or clearing a bit in registers ie. the ie register also contains a global disable bit, ea, which disables all interrupts at once.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 47 - revision a1 3 each interrupt source can be individually programmed to one of 2 priority levels by setting or cleari ng bits in the ip registers. an interrupt service routine in progress can be interrupted by a higher priority interrupt, but not by another interrupt of the same or lower priority. the highest priority interrupt service cannot be interrupted by any other i nterrupt source. so, if two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. if requests of the same priority level are received simultaneously, an internal polling sequence dete r- mines wh ich request is serviced. this is called the arbitration ranking. note that the arbitration ranking is only used to resolve simultaneous requests of the same priority level. table below summarizes the interrupt sources, flag bits, vector addresses, enable bits, priority bits, arbitration ranking, and external interrupt may wake up the cpu from power down mode. source flag vector a d dress enable bit interrupt priority flag cleared by arbitr a tion ran k ing power - down wakeup external interrupt 0 ie0 0003h ex0 ( ie.0) iph.0, ip.0 hardware, software 1(highest) yes timer 0 overflow tf0 000bh et0 (ie.1) iph. 1 , ip. 1 hardware, software 2 no external interrupt 1 ie1 0013h ex1 (ie.2) iph. 2 , ip. 2 hardware, software 3 yes timer 1 overflow tf1 001bh et1 (ie.3) iph. 3 , ip. 3 hardware, software 4 no serial port ri + ti 0023h es (ie.4) iph. 4 , ip. 4 software 5 no timer 2 ove r- flow/match tf2 002bh et2 (ie. 5 ) iph. 5 , ip. 5 software 6 no external interrupt 2 ie2 0033h ex2 ( xicon.2 ) iph. 6 , px2 hardware, software 7 yes external i nterrupt 3 ie3 003bh ex3 ( xicon.6 ) iph. 7 , px3 hardware, software 8(lowest) yes table 13 C 2 summary of interrupt sources 13.3 interrupt response time the response time for each interrupt source depends on several factors, such as the nature of the i n- terrupt and the instruction underway. in the case of external interrupts and , they are sa m- pled at s5p2 of every machine cycle and then their corresponding interrupt flags iex will be set or r e- set. the timer 0 and 1 overflow flags are set at c3 of the machine cycle in which overflow has o c- curred. these flag values are polled only in the next machine cycle. if a request is active and all three conditions are met, then the ha rdware generated lcall is executed. this lcall itself takes four m a- chine cycles to be completed. thus there is a minimum time of five machine cycles between the inte r- rupt flag being set and the interrupt service routine being executed. a longer response t ime should be anticipated if any of the three conditions are not met. if a higher or equal priority is being serviced, then the interrupt latency time obviously depends on the nature of the service routine currently being executed. if the polling cycle is not the last machine cycle of the instru c- tion being executed, then an additional delay is introduced. the maximum response time (if no other int0 int1
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 48 - revision a1 3 interrupt is in service) occurs if the device is p erforming a write to ie, ip, ip h and then executes a mul or div i nstruction. 13.4 interrupt inputs since the external interrupt pins are sampled once each machine cycle, an input high or low should hold for at least one machine cycle to ensure proper sampling. if the external interrupt is high for at least one machine cycl e, and then hold it low for at least one machine cycle. this is to ensure that the transition is seen and that interrupt request flag ien is set. ien is automatically cleared by the cpu when the service routine is called. if the external interrupt is leve l - activated, the external source must hold the request active until the requested interrupt is actually generated. if the external interrupt is still asserted when the interrupt service routine is completed another interrupt will be generated. it is not ne cessar y to clear the inte r- rupt flag ie n when the interrupt is level sensitive, it simply tracks the input pin level. if an external interrupt is enabled when the w78e054d/w78e052d is put into power down or idle mode, the interrupt will cause the processor to wake up and resume operation. refer to the section on power reduction modes for details.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 49 - revision a1 3 14 programmable timers/counters the w78e054d/w78e052d series have three 16 - b it programmable timer/counters. a machine cycle equals 12 or 6 oscillator periods, and it depends on 12t mode or 6t mode that the user configured this device. 14.1 timer/counters 0 & 1 w78e054d/w78e052d has two 16 - bit timer/counters. each of these timer/counters has two 8 bit registers which form the 16 bit counting register. for timer/counter 0 they are th0, the upper 8 bits register, and tl0, the lower 8 bit register. similarly timer/counter 1 has two 8 bit regi s ters, th1 and tl1. the two can be configured to operate either as timers, counting machine cycles or as counters counting external inpu ts. when configured as a "timer", the timer counts clock cycles. the timer clock can be programmed to be thought of as 1/12 of the system clock. in the "counter" mode, the register is incremented on the falling edge of the external input pin, t0 in case o f timer 0, and t1 for timer 1. the t0 and t1 inputs are sampled in every machine cycle at c4. if the sampled value is high in one machine cycle and low in the next, then a valid high to low transition on the pin is recognized and the count register is incr e- mented. since it takes two machine cycles to recognize a negative transition on the pin, the maximum rate at which counting will take place is 1/24 of the master clock frequency. in either the "timer" or "counter" mode, the count register will be updated at c3. therefore, in the "timer" mode, the reco g- nized negative transition on pin t0 and t1 can cause the count register value to be updated only in the machine cycle following the one in which the negative edge was detected. the "timer" or "counter" funct ion is selected by the " " bit in the tmod special function register. each timer/counter has one selection bit for its own; bit 2 of tmod selects the function for ti m- er/counter 0 and bit 6 of tmod selects the function for timer/counter 1. i n addition each ti m- er/counter can be set to operate in any one of four possible modes. the mode selection is done by bits m0 and m1 in the tmod sfr. 14.2 time - base selection w78e054d/w78e052d provides users with two modes of operation for the timer. the timers can be programmed to operate like the standard 8051 family, counting at the rate of 1/12 of the clock speed. this will ens ure that timing loops on w78e054d/w78e052d and the stan d ard 8051 can be matched. this is the d efault mode of operation of the w78e054d /w78e052d timers. 14.2.1 mode 0 in mode 0, the timer/counter is a 13 - bit counter. the 13 - bit counter consists of thx (8 msb) and the five lower bits of tlx (5 lsb). the upper three bits of tlx are ignored. the timer/counter is enabled when trx is set and either g ate is 0 or is 1. when is 0, the timer/counter counts clock cycles; when is 1, it counts falling edges on t0 (timer 0) or t1 (timer 1). for clock cycles, the time base be 1/12 speed, a nd the falling edge of the clock increments the counter. when the 13 - bit value moves from 1fffh to 0000h, the timer overflow flag tfx is set, and an interrupt occurs if en a- bled. 14.2.2 mode 1 mode 1 is similar to mode 0 except that the counting register forms a 16 - bit counter, rather than a 13 - bit counter. this means that all the bits of thx and tlx are used. roll - over occurs when the timer moves from a count of 0 ffffh to 0000h. the timer overflow flag tfx of the relevant timer is set and if enabled an interrupt will occur. the selection of the time - base in the timer mode is similar to that in mode 0. the gate function operates similarly to that in mode 0. t c/ intx t c /
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 50 - revision a1 3 figure 14 C 1 timer/counters 0 & 1 in mode 0, 1 14.2.3 mode 2 in mode 2, the timer/counter is in the auto reload mode. in this mode, tlx acts as an 8 - bit count re g- ister, while thx holds the reload value. when the tlx register overflows from ffh to 00h, the tfx bit in tcon is set and tlx is relo aded with the contents of thx, and the counting process continues from here. the reload operation leaves the contents of the thx register unchanged. counting is enabled by the trx bit and proper setting of gate and pins. as in the other t wo modes 0 and 1 mode 2 a l- lows counting of clock/12 or pulses on pin tn. figure 14 C 2 timer/counter 0 & 1 in mode 2 14.2.4 mode 3 mode 3 has different operating methods for the two tim er/counters. for timer/counter 1, mode 3 simply freezes the counter. timer/counter 0, however, configures tl0 and th0 as two separate 8 bit count registers in this mode. the logic for this mode is shown in the figure. tl0 uses the timer/counter 0 control b its , gate, tr0, and tf0. the tl0 can be used to count clock cycles (clock/12) or 1 - to - 0 transitions on pin t0 as determined by c/t (tmod.2). th0 is forced as a clock cycle counter (clock/12) and takes over the use of tr1 and tf1 from timer/counter 1. mode 3 is used in cases where an extra 8 bit timer is needed. with timer 0 in mode 3, timer 1 can still be used in modes 0, 1 1 / 1 2 f o s c t 0 = p 3 . 4 ( t 1 = p 3 . 5 ) 0 1 t r 0 = t c o n . 4 ( t r 1 = t c o n . 6 ) g a t e = t m o d . 3 ( g a t e = t m o d . 7 ) i n t 0 = p 3 . 2 ( i n t 1 = p 3 . 3 ) c / t = t m o d . 2 ( c / t = t m o d . 6 ) 0 7 0 7 t f x i n t e r r u p t t l 0 ( t l 1 ) t h 0 ( t h 1 ) t f 0 ( t f 1 ) t i m e r / c o u n t e r m o d e 0 , 1 4 m 1 , m 0 = t m o d . 1 , t m o d . 0 ( m 1 , m 0 = t m o d . 5 , t m o d . 4 ) 0 0 0 1 intx 1 / 1 2 f o s c t 0 = p 3 . 4 ( t 1 = p 3 . 5 ) 0 1 t r 0 = t c o n . 4 ( t r 1 = t c o n . 6 ) g a t e = t m o d . 3 ( g a t e = t m o d . 7 ) i n t 0 = p 3 . 2 ( i n t 1 = p 3 . 3 ) c / t = t m o d . 2 ( c / t = t m o d . 6 ) 0 7 0 7 t f x i n t e r r u p t t l 0 ( t l 1 ) t h 0 ( t h 1 ) t f 0 ( t f 1 ) t i m e r / c o u n t e r m o d e 2 t c/ int0
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 51 - revision a1 3 and 2, but its flexibility is somewhat limited. while its basic functionality is maintained, it no longer has control over its overflow flag tf1 and the enable bit tr1. timer 1 can still be used as a timer/counter and retains the use of gate and int1 pin. in this condition it can be turned on and off by switching it out of and into its own mode 3. it ca n also be used as a baud rate generator for the serial port. figure 14 C 3 timer/counter mode 3 14.3 timer/counter 2 timer/counter 2 is a 16 bit up/down counter which is configured b y the t2mod(bit 0) register and co n trolled by the t2con register. timer/counter 2 is equipped with a capture/reload capability. as with the timer 0 and timer 1 counters, there exists considerable flexibility in selecting and controlling the clock, and in d efining the operating mode. the clock source for timer/counter 2 may be selected for either the external t2 pin (c/t2 = 1) or the crystal oscillator, which is divided by 12 (c/t2 = 0). the clock is then enabled when tr2 is a 1, and disabled when tr2 is a 0. 14.3.1 capture mode the capture mode is enabled by setting the bit in the t2con register to a 1. in the capture mode, timer/counter 2 serves as a 16 bit up counter. when the counter rolls over from 0 ffffh to 0000h, the tf2 bit is set, whic h will generate an interrupt request. if the exen2 bit is set, then a neg a- tive transition of t2ex pin will cause the value in the tl2 and th2 register to be captured by the rcap2l and rcap2h registers. this action also causes the exf2 bit in t2con to be se t, which will also generate an interrupt. (rclk,tclk, )= (0,0,1) 1 / 1 2 f o s c t 0 = p 3 . 4 0 1 t r 0 = t c o n . 4 g a t e = t m o d . 3 i n t 0 = p 3 . 2 c / t = t m o d . 2 0 7 0 7 t f 0 i n t e r r u p t t l 0 t h 0 t r 1 = t c o n . 6 t f 1 i n t e r r u p t cp rl / 2 rl2 cp /
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 52 - revision a1 3 figure 14 C 4 16 - bit capture mode 14.3.2 auto - reload mode, counting up the auto - reload mode as an up counter is enabled by clearing the bit in the t2con register and clearing the dcen bit in t2mod(bit0) register. in this mode, timer/counter 2 is a 16 bit up cou n- ter. when the counter rolls over from 0 ffffh, a reload is generated th at causes the contents of the rcap2l and rcap2h registers to be reloaded into the tl2 and th2 registers. the reload action also sets the tf2 bit. if the exen2 bit is set, then a negative transition of t2ex pin will also cause a r e load. this action also set s the exf2 bit in t2con. (rclk,tclk, )= (0,0,0) & dcen= 0 figure 14 C 5 16 - bit auto - reload mode, counting up 14.3.3 auto - reload mode, counting up/down timer/count er 2 will be in auto - reload mode as an up/down counter if bit in t2con is cleared and the dcen bit in t2mod is set. in this mode, timer/counter 2 is an up/down counter whose direction is controlled by the t2ex pin. a 1 on this pin cause t he counter to count up. an ove r- flow while counting up will cause the counter to be reloaded with the contents of the capture registers. the next down count following the case where the contents of timer/counter equal the capture regi s- ters will load a 0 ffff h into timer/counter 2. in either event a reload will set the tf2 bit. a reload will also toggle the exf2 bit. however, the exf2 bit cannot generate an interrupt while in this mode. (rclk,tclk, )= (0,0,0) & dcen= 1 cp rl / 2 rl2 cp / 1 / 1 2 f o s c t 2 = p 1 . 0 0 1 t 2 e x = p 1 . 1 c / t 2 = t 2 c o n . 1 e x f 2 t i m e r 2 i n t e r r u p t t 2 c o n . 6 t r 2 = t 2 c o n . 2 e x e n 2 = t 2 c o n . 3 t l 2 t h 2 r c a p 2 l r c a p 2 h t f 2 t 2 c o n . 7 1 / 1 2 f o s c t 2 = p 1 . 0 0 1 c / t 2 = t 2 c o n . 1 e x f 2 t i m e r 2 i n t e r r u p t t 2 c o n . 6 t r 2 = t 2 c o n . 2 t l 2 t h 2 r c a p 2 l r c a p 2 h t f 2 t 2 c o n . 7
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 53 - revision a1 3 figure 14 C 6 16 - bit auto - reload mode, counting up 14.3.4 baud rate generator mode the baud rate generator mode is enabled by setting either the rclk or tclk bits in t2con register. while in the baud rate generator mode, timer/counter 2 is a 16 bit counter with auto reload when the count rolls over from 0 ffffh. however, rolling over does not set the tf2 bit. if exen2 bit is set, then a negative transition of the t2ex pin will set exf2 bit in the t2con regi ster and cause an interrupt r e quest. rclk+tclk=1, =0 figure 14 C 7 baud rate generator mode rl2 cp / 1 / 1 2 f o s c t 2 = p 1 . 0 0 1 t 2 e x = p 1 . 1 c / t 2 = t 2 c o n . 1 e x f 2 t i m e r 2 i n t e r r u p t t 2 c o n . 6 t r 2 = t 2 c o n . 2 t l 2 t h 2 r c a p 2 l r c a p 2 h t f 2 t 2 c o n . 7 0 f f h 0 f f h d o w n c o u n t i n g r e l o a d v a l u e u p c o u n t i n g r e l o a d v a l u e f o s c t 2 = p 1 . 0 0 1 t 2 e x = p 1 . 1 c / t 2 = t 2 c o n . 1 e x f 2 t i m e r 2 i n t e r r u p t t 2 c o n . 6 t r 2 = t 2 c o n . 2 e x e n 2 = t 2 c o n . 3 t l 2 t h 2 r c a p 2 l r c a p 2 h 1 / 1 6 1 / 1 6 1 1 0 0 r c l k = t 2 c o n . 5 t c l k = t 2 c o n . 4 1 / 2 0 1 t i m e r 1 o v e r f l o w s m o d = p c o n . 7 r x c l o c k t x c l o c k t i m e r 2 o v e r f l o w 1 / 2
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 54 - revision a1 3 15 watchdog timer the watchdog timer is a free - running timer whic h can be programmed by the user to serve as a sy s- tem monitor, a time - base generator or an event timer. it is basically a set of dividers that divide the system clock. the divider output is selectable and determines the time - out interval. when the time - out occurs a system reset can also be caused if it is enabled. the main use of the watchdog timer is as a system monitor. this is important in real - time control applications. in case of power glitches or electro - magnetic interference, the processor may begin t o execute errant code. if this is left unchecked the entire system may crash. the watchdog time - out selection will result in different time - out values d e- pending on the clock speed. the watchdog timer will de disabled on reset. in general, software should r estart the watchdog timer to put it into a known state. the control bits that support the watchdog ti m- er are discussed below. enw : enable watchdog if set. clrw : clear watchdog timer and p re - scal a r if set. this flag will be cleared automatically widl : if this bit is set, watch - dog is enabled under idle mode. if cleared, watchdog is disabled u n- der idle mode. default is cleared. ps2, ps1, ps0: watchdog p re - scal a r timer select. p re - scal a r is selected when set ps2 ? 0 as follows: ps2 ps1 ps0 p re - scal a r s elect 0 0 0 2 0 0 1 8 0 1 0 4 0 1 1 16 1 0 0 32 1 0 1 64 1 1 0 128 1 1 1 256 the time - out period is obtained using the following equation for 12t per machine cycle : before watchdog time - out occurs, the program must clear the 14 - bit timer by writing 1 to wdtc.6 (clrw). after 1 is written to this bit, the 14 - bit timer, p re - scal a r and this bit will be reset on the next instruction cycle. t he watchdog timer is cleared on reset. ms scalar e osc 12 1000 pr 2 1 14 ? ? ? ? ?
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 55 - revision a1 3 figure 15 C 1 watchdog timer block diagram typical watch - dog time - out period when osc = 20 mhz ps2 ps1 ps0 watchdog time - out period (for 12t per machine cycle) 0 0 0 19.66 ms 0 1 0 78.64 ms 0 0 1 39.32 ms 0 1 1 157.28 ms 1 0 0 314.57 ms 1 0 1 629.14 ms 1 1 0 1.25 s 1 1 1 2.50 s table 15 C 2 watch - dog time - out period for 12t per machine cycle, 20mhz ps2 ps1 ps0 watchdog time - out period (for 6t per machine cycle) 0 0 0 9.83 ms 0 1 0 39.32 ms 0 0 1 19.66 ms 0 1 1 78.64 ms 1 0 0 157.28 ms 1 0 1 314.57 ms 1 1 0 629.14 ms 1 1 1 1 . 2 50 s table 15 C 3 watch - dog time - out period for 6t per machine cycle , 20mhz 16 serial port o s c 1 / 1 2 1 / 6 p r e - s c a l a r 1 4 - b i t t i m e r c l e a r c l r w e x t e r n a l r e s e t i n t e r n a l r e s e t w i d l i d l e e n w
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 56 - revision a1 3 serial port in this device is a full duplex port. the serial port is capable of synchronous as well as asynchronous communication. in synchronous mode the device generates the clock and operates in a half - duplex mode. in the asynchronou s mode, full duplex operation is available. this means that it can simultaneously transmit and receive data. the transmit register and the receive buffer are both a d- dressed as sbuf special function register. however any write to sbuf will be to the transmi t regi s- ter, while a read from sbuf will be from the receiver buffer register. the serial port can operate in four different modes as described below. 16.1 mode 0 this mode provides synchronous communication with external devices. in this mode serial data is tr ansmitted and received on the rxd line. txd is used to transmit the shift clock. the txd clock is provided by the device whether it is transmitting or receiving. this mode is therefore a half - duplex mode of serial communication. in this mode, 8 bits are tr ansmitted or received per frame. the lsb is transmitted/received first. the baud rate is fixed at 1/12 of the oscillator frequency. this baud rate is determined by the sm2 bit (scon.5). when this bit is set to 0, then the serial port runs at 1/12 of the cl ock. this additional facility of programmable baud rate in mode 0 is the only difference between the standard 8051 and w78e054d/w78e052d . the functional block diagram is shown below. data enters and leaves the serial port on the rxd line. the txd line is used to output the shift clock. the shift clock is used to shift data into and out of this device and the device at the other end of the line. any instruction that causes a write to sbuf will start the transmission. the shift clock will be activated and da ta will be shifted out on the rxd pin till all 8 bits are transmitted. if sm2 = 1, then the data on rxd will appear 1 clock period before the falling edge of shift clock on txd. the clock on txd then remains low for 2 clock periods, and then goes high agai n. if sm2 = 0, the data on rxd will appear 3 clock periods before the falling edge of shift clock on txd. the clock on txd then remains low for 6 clock periods, and then goes high again. this ensures that at the receiving end the data on rxd line can eithe r be clocked on the rising edge of the shift clock on txd or latched when the txd clock is low.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 57 - revision a1 3 figure 16 C 1 s erial port mode 0 the ti flag is set high in s6p2 following the end of transmission of the last bit. the serial port will r e- ceive data when ren is 1 and ri is zero. the shift clock (txd) will be activated and the serial port will latch data on the rising edge of shift clock. the external device should therefore present data on the falling edge on the shift clock. this process continues till all the 8 bits have been received. the ri flag is set in s6p2 following the last rising edge of the shift clock on txd. this will stop reception, till the ri is cleared by software. 16.2 mode 1 in mode 1, the full duplex asynchronous mode is used. serial communication frames are made up of 10 bits transmitted on txd and received on rxd. the 10 bits consist of a start bit (0), 8 data bits (lsb first), and a stop bit (1). on receive, the sto p bit goes into rb8 in the sfr scon. the baud rate in this mode is variable. the serial baud can be programmed to be 1/16 or 1/32 of the timer 1 overflow. since the timer 1 can be set to different reload values, a wide variation in baud rates is possible. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at s6p2 follo w- ing the first roll - over of divide by 16 counter. the next bit is placed on txd pin at s6p2 following the next rollover of the divide by 16 counter. thus t he transmission is synchronized to the divide by 16 counter and not directly to the write to sbuf signal. after all 8 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the s6p2 state after the stop bit has been put out on txd pin. this will be at the 10th rollover of the divide by 16 counter s after a write to sbuf. reception is enabled only if ren is high. the serial port actually starts the receiving of serial data, with the detection of a falling edge on the rxd pin. the 1 - to - 0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counter s is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counter s . the 16 states of the counter effectively divide the bit time into 16 slices. the bit detection is done on a 1 / 1 2 f o s c 0 t x c l o c k r x c l o c k t i r i t x s h i f t t x s t a r t r x s h i f t l o a d s b u f s h i f t c l o c k r i r e n s m 2 c l o c k s i n p a r o u t s b u f r e a d s b u f i n t e r n a l d a t a b u s s e r i a l c o n t r o l l o r c l o c k l o a d p a r i n t x s t a r t i n t e r n a l d a t a b u s w r i t e t o s b u f s o u t t r a n s m i t s h i f t r e g i s t e r s e r i a l i n t e r r u p t r x d t x d r x d p 3 . 0 a l t e r n a t e i n p u t f u n c t i o n p 3 . 0 a l t e r n a t e o u t p u t f u n c t i o n p 3 . 1 a l t e r n a t e o u t p u t f u n c t i o n 1 / 4 1 r e c e i v e s h i f t r e g i s t e r
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 58 - revision a1 3 best of three basis. the bit detector samples the rxd pin, at the 8th, 9th and 10th counter states. by using a majority 2 of 3 voting system, the bit value is selected. this is done to improve the noise reje c- tion feature of the serial port. if the first bit detected after the falling edge of rxd pin is not 0, then this indicates an invalid start bit, and the reception is immedia tely aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bits are also detected and shifted into the sbuf. after shifting in 8 data bits, there is one more shift to do, after whi ch the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these conditions are met, then the stop bit goe s to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1 - to - 0 transition on the rxd pin. figure 16 C 2 serial port mode 1 16.3 mode 2 this mode uses a total of 11 bits in asynchronous full - duplex communication. the functional descri p- tion is shown in the figure below. the frame consists of one start bit (0), 8 data bits ( lsb first), a pr o- grammable 9th bit (tb8) and a stop bit ( 1 ). the 9th bit received is put into rb8. the baud rate is pr o- grammable to 1/32 or 1/64 of the oscillator frequency, which is determined by the smod bit in pcon sfr. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at s6p2 following the first roll - over of the divide by 16 counter. the next bit is placed on txd pin at s6p2 fo l- 1 / 2 1 / 16 tx clock rx clock ti ri tx shift tx start rx shift load sbuf smod clock sin d 8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus write to sbuf sout transmit shift register serial interrupt txd rxd parout rb 8 start stop 0 1 bit detector 1 - to - 0 detector sample 1 / 16 0 timer 1 overflow 1 receive shift register 0 1 0 1 tclk rclk timer 2 overflow
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 59 - revision a1 3 lowing the next rollover of the divide by 16 counter. thus the transmission is synchronize d to the d i- vide by 16 counter s , and not directly to the write to sbuf signal. after all 9 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the s6p2 state after the stop bit has been put out on txd pin. this will be at the 11 th rollover of the divide by 16 counter s after a write to sbuf. reception is enabled only if ren is high. the serial port actually starts the receiving of serial data, with the d e- te c tion of a falling edge on the rxd pin. the 1 - to - 0 detector continuously mo nitors the rxd line, sa m- pling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counter s is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counter s . the 16 states of the counter effectively divide the bit time into 16 slices. the bit detection is done on a best of three basis. the bit detector samples the rxd pin, at the 8th, 9th and 10th cou n- ter states. by using a majority 2 of 3 voting system, the bit valu e is selected. this is done to i m prove the noise rejection feature of the serial port. figure 16 C 3 serial port mode 2 if the first bit detected after the falling edge of rxd pin, is not 0, then this indicates an invalid start bit, and the reception is immediately aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bits are also detected and shifted int o the sbuf. a f- ter shifting in 9 data bits, there is one more shift to do, after which the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these conditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1 - to - 0 transition on the rxd pin. 1 / 2 1 / 16 tx clock rx clock ti ri tx shift tx start rx shift load sbuf smod clock sin d 8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus write to sbuf sout transmit shift register serial interrupt txd rxd parout rb 8 start stop 0 1 bit detector 1 - to - 0 detector sample 1 / 16 0 fosc / 2 1 d 8 tb 8 receive shift register
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 60 - revision a1 3 mode 3 this mode is similar to mode 2 in all respects, except that the baud rate is programmable. the user must first initialize the serial related sfr scon before any communication can take place. this i n- volves selection of th e mode and baud rate. the timer 1 should also be initialized if modes 1 and 3 are used. in all four modes, transmission is started by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by the condition ri = 0 and ren = 1. this will generate a clock on the txd pin and shift in 8 bits on the rxd pin. reception is initiated in the other modes by the incoming start bit if ren = 1. the external device will start the communication by transmitting the start bit. figure 16 C 4 serial port mode 3 sm0 sm1 mode type baud clock frame size start bit stop bit 9th bit function 0 0 0 synch. 4 or 12 tclks 8 bits no no none 0 1 1 asynch. timer 1 or 2 10 bit s 1 1 none 1 0 2 asynch. 32 or 64 tclks 11 bits 1 1 0, 1 1 1 3 asynch. timer 1 or 2 11 bits 1 1 0, 1 table 16 C 5 serial ports modes t x c l o c k r x c l o c k t i r i t x s h i f t t x s t a r t r x s h i f t l o a d s b u f c l o c k s i n d 8 s b u f r e a d s b u f i n t e r n a l d a t a b u s s e r i a l c o n t r o l l o r c l o c k l o a d p a r i n t x s t a r t i n t e r n a l d a t a b u s w r i t e t o s b u f s o u t t r a n s m i t s h i f t r e g i s t e r s e r i a l i n t e r r u p t t x d r x d p a r o u t r b 8 s t a r t s t o p 0 1 b i t d e t e c t o r 1 - t o - 0 d e t e c t o r d 8 t b 8 r e c e i v e s h i f t r e g i s t e r 1 / 2 1 / 1 6 s m o d s a m p l e 1 / 1 6 0 t i m e r 1 o v e r f l o w 1 0 1 0 1 t c l k r c l k t i m e r 2 o v e r f l o w
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 61 - revision a1 3 17 flash rom code boot mode s lection the w78e054d/w78e052d boots from aprom program ( 16k/8k bytes) or ldrom program (2k bytes) at power on reset or external reset . boot mode select by config bit s cbs (config.2) config boot select at power - on reset and external reset. 1: boot from ap rom ( 0x0000 ). 0: boot from ld rom (0x3800).
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 62 - revision a1 3 18 i sp ( in - system programming ) isp is the ability of progr am mcu to b e programmed while f/w code in ap - rom or ld - rom. ( note: t imer 0 for program, erase, read on isp mode . isp operation voltage 3.3 - 5.5v ) start setting control registers mov sfrcn,#3fh mov sfrfd,#abh mov sfral,#ffh mov sfrah,#ffh mov chpcon,#03h setting timer (about 450 us) and enable timer interrupt start timer and enter idle mode. (cpu will be wakened from idle mode by timer interrupt, then enter in - system programming mode) part 1:2kb aprom procedure of entering in - system programming mode execute the normal application program enter in - system programming mode ? (conditions depend on user's application) end yes go no
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 63 - revision a1 3 go timer interrupt service routine: stop timer & disable interrupt end of programming end of erase operation. cpu will be wakened by timer interrupt. setting timer and enable timer interrupt for wake - up . (15 ms for erasing operation) start timer and enter idle mode. (erasing...) part 2: procedure of updating the 2kb aprom is f02k boot mode? setting erase operation mode: mov erpage,#02h mov sfrcn,#22h (erase 2kb aprom isp ) pgm no yes
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 64 - revision a1 3 pgm read_device_id mov sfrcn,#0ch mov chpcon,#03h setting timer and enable timer interrupt for wake - up . (50us for program operation) read_vt mov sfrcn,#0dh mov sfral,#01h mov sfrah,#00h mov chpcon,#03h . part 2: procedure of updating the 2kb aprom end of programming ? get the parameters of new code (address and data bytes) through i/o ports, uart or other interfaces . setting control registers for programming: mov sfrah,#address_h mov sfral,#address_l mov sfrfd,#data mov sfrcn,#21h no yes read_compay_id ov sfrcn,#0bh mov chpcon,#03h read_dist mov sfrcn,#0eh mov sfral,#02h mov sfrah,#00h mov chpcon,#03h . is currently in the f02k boot mode ? ease 14k ap programming: mov erpage,#01 mov sfrcn,#22h
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 65 - revision a1 3 pgm software reset cpu and re - boot from the 2kb aprom. mov chpcon,#81h hardware reset to re - boot from new 2 kb aprom. (s/w reset is invalid in f02k boot mode) setting timer and enable timer interrupt for wake - up . (50us for program operation) end executing new code from address 00h in the 2kb aprom. part 2: procedure of updating the 2kb aprom end of programming ? get the parameters of new code (address and data bytes) through i/o ports, uart or other interfaces . setting control registers for programming: mov sfrah,#address_h mov sfral,#address_l mov sfrfd,#data mov sfrcn,#21h is currently in the f02k boot mode ? no yes no yes read_compay_id read_device_id read_vt read_dist ease 14k ap programming: mov erpage,#01 mov sfrcn,#22h
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 66 - revision a1 3 19 config bits during the on - chip flash eprom operation mode, the flash eprom can be programmed and ver i- fied repeatedly. until the code inside the flash eprom is confirmed ok, the cod e can be protected. the protection of flash eprom and those operations on it are described below. the w78e054d/w78e052d has a special setting register, the config bits, which cannot be accessed in normal mode. the security register can only be accessed fro m the flash eprom o p eration mode. those bits of the security registers cannot be changed once they have been pr o grammed from high to low. they can only be reset through erase - all operation. the security register is addressed in the flash eprom operation mo de by address #0ffffh. s p e c i a l s e t t i n g r e g i s t e r c o n f i g b i t s 1 6 / 8 / 4 k b f l a s h e p r o m p r o g r a m m e m o r y r e s e r v e d s e c u r i t y r e g i s t e r f f f f h 0 0 0 0 h 3 f f f h b 0 : l o c k b i t , l o g i c 0 : a c t i v e l o c k f l a s h l o g i c 1 : n o l o c k f l a s h . b 1 : m o v c i n h i b i t , l o g i c 0 : t h e m o v c i n s t r u c t i o n i n e x t e r n a l m e m o r y c a n n o t a c c e s s t h e c o d e i n i n t e r n a l m e m o r y l o g i c 1 : n o r e s t r i c t i o n . b 2 : c b s l o g i c 0 : b o o t f r o m l d b l o c k ( 0 x 3 8 0 0 ) . l o g i c 1 : b o o t f r o m a p b l o c k ( d e f a u l t ) . b 3 : n s r ( n o i s e s e n s i t i v i t y r e d u c t i o n ) l o g i c 0 : n o i s e s e n s i t i v i t y r e d u c t i o n i s e n a b l e d . l o g i c 1 : n o i s e s e n s i t i v i t y r e d u c t i o n i s d i s a b l e d . b 5 : m a c h i n e c y c l e s e l e c t l o g i c 0 : 6 t l o g i c 1 : 1 2 t b 7 : c r y s t a l s e l e c t l o g i c 0 : 1 / 2 g a i n , 2 4 m h z l o g i c 1 : f u l l g a i n , 4 0 m h z d e f a u l t 1 f o r a l l s e c u r i t y b i t s . r e s e r v e d b i t s m u s t b e k e p t i n l o g i c 1 . b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 67 - revision a1 3 bit 0: lock bits 0: lock enable 1: lock disable this bit is used to protect the customer's program code in the w78e054d/w78e052d . it may be set after the programmer finishes the programming and veri fies sequence. once these bits are set to logic 0, both the flash data and special setting registers cannot be accessed again. bit 1: movc inhibit 0: movc inhibit enable 1: movc inhibit disable this bit is used to restrict the accessible region of the mo vc instruction. it can prevent the movc i n- struction in external program memory from reading the internal program code. when this bit is set to logic 0, a movc instruction in external program memory space will be able to access code only in the external mem ory, not in the internal memory. a movc instruction in internal program memory space will always be able to access the rom data in both internal and external memory. if this bit is logic 1, there are no restrictions on the movc instruction. bit 2: cbs con fig boot select at power - on reset and external reset. cbs= 1: boot from ap rom block (default). cbs= 0: boot from ld rom block (0x3800). bit 3: nsr (noise sensitivity reduction) nsr=1: noise sensitivity reduction is disabled. nsr=0: noise sensitivity reductio n is enabled. bit 4 : must be 1 bit 5: machine cycle select this bit is select mcu cor e, default value is logic 1 , and the mcu core is 12t per instruction . once this bit is set to logic 0, the mcu core is 6t per instruction . bit 6 : must be 1 bit 7: crystal select 0 (24mhz) : if system clock is slow er than 24mhz, programming 0 . it can reduce emi effect and save the power co n sumption. 1 (40mhz) : if system clock is fast er than 24mhz, programming 1 .
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 68 - revision a1 3 20 electrical characteristics 20.1 absolute maximum rating s symbol parameter min max unit dc power supply v dd ? v ss 2. 4 5 .5 v input voltage v in v ss - 0.3 v dd +0.3 v operating temperature ( w78e054d/w78e052d ) t a - 40 + 85 ? c note: exposure to conditions beyond those listed under absolute maximum ratings may adversely a f- fects the lift and reliability of the device.
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 69 - revision a1 3 20.2 dc electrical characteristics t a = - 40 ~+85 , v dd =2.4v~5.5v, v ss =0v sym parameter test condition min typ *1 max unit v il input low voltage ( ports 0~4, /ea, xtal1, rst) 2.4 < v dd < 5.5v - 0.5 0.2v dd - 0.1 v v ih input high voltage ( ports 0~4, /ea) 2.4 < v dd < 5.5v 0.2v dd +0.9 v dd + 0.5 v v ih1 in put high voltage (xtal1, rst) 2.4 < v dd < 5.5v 0.7v dd v dd + 0.5 v v ol output low voltage ( ports 0~4, ale, /psen) v dd =4.5v, i ol = 1 2 .0ma *3,*4 v dd =2.4v, i ol = 10ma *3,*4 0.4 v v oh1 output high voltage ( ports 1~4) v dd =4.5v, i oh = - 300 ? *4 v dd =2.4v, i oh = - 35 ? *4 2.4 2.0 v v oh2 output high voltage (ports 0 & 2 in external bus mode, ale, /psen) v dd =4.5v, i oh = - 8 .0ma *4 v dd =2.4v, i oh = - 2.2ma *4 2.4 2.0 v i il logical 0 input current ( ports 1~4) v dd =5.5v, v in =0.4v - 45 - 5 0 ? i tl logical 1 - to - 0 transition curr ent ( ports 1~4) *2 v dd =5.5v, v in =2.0v - 510 - 650 ? i li input leakage current ( port 0) 0 < v in < v dd +0.5 ? i dd power supply current active mode *5 @12mhz, v dd =5.0v @40mhz, v dd =5.0v @12mhz, v dd =3.3v @20mhz, v dd =3.3v 9. 5 1 6 .0 3. 1 3. 7 ma i dle mode @12mhz, v dd =5.0v @40mhz, v dd =5.0v @12mhz, v dd =3.3v @20mhz, v dd =3.3v 3.5 9. 2 1. 2 1.7 ma power - down mode <1 50 ? r rst rst - pin internal pull - down resistor 2.4 < v dd < 5.5v 100 225 k *1: typical values are not guaranteed. the values listed are tested at room temperature and based on a limited number of samples .
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 70 - revision a1 3 *2: pins of ports 1~4 source a transition current when they are being externally driven from 1 to 0. the transition c urrent reaches its maximum value when v in is approximatel y 2v. *3: under steady state (non - transient) conditions, i ol must be externally limited as follows: maximum i ol per port pin : 20ma maximum i ol per 8 - bit port : 40ma maximum total i ol for all outputs : 100ma *4: if i oh exceeds the test condition, v oh will be lower than the listed specification. if i ol exceeds the test condition, v ol will be higher than the listed specification. *5: tested while cpu is kept in reset state and ea=h, port0=h . voltage max . frequency 6t/12t mode note 4.5 - 5.5v 40mhz 12t 4.5 - 5.5v 20mhz 6t 2.4 v 20mhz 12t 2.4 v 10mhz 6t frequency vs voltage table 20.3 ac electrical characteristics the ac specifications are a function of the particular process used to manufacture the part, the ratings of the i/o buffers, the capacitive lo ad, and the internal routing capacitance. most of the specifications can be expressed in terms of multiple input clock periods (tcp), and actual parts will usually exper i- ence less than a ? 20 ns variation. 20.3.1 clock input waveform parameter symbol min. typ. max. unit notes operating speed fop 0 - 40 mhz 1 clock period tcp 25 - - ns 2 clock high tch 10 - - ns 3 clock low tcl 10 - - ns 3 notes: 1. the clock may be stopped indefinitely in either state. 2. the tcp specifica tion is used as a reference in other specifications. 3. there are no duty cycle requirements on the xtal1 input. t t xtal1 f ch cl op, t cp
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 71 - revision a1 3 20.3.2 program fetch cycle parameter symbol min. typ. max. unit notes address valid to ale low taas 1 tcp - ? - - ns 4 address hold from ale low ta ah 1 tcp - ? - - ns 1, 4 ale low to low tapl 1 tcp - ? - - ns 4 low to data valid tpda - - 2 tcp ns 2 data hold after high tpdh 0 - 1 tcp ns 3 data float after high tpdz 0 - 1 tcp ns ale pulse width talw 2 tcp - ? 2 tcp - ns 4 pul se width tpsw 3 tcp - ? 3 tcp - ns 4 notes: 1. p0.0 ? p0.7, p2.0 ? p2.7 remains stable throughout entire memory cycle. 2. memory access time is 3 tcp. 3. data have been latched internally prior to going high. 4. " ? " (due to buffer driving delay and wire l oading) is 20 ns. 20.3.3 data read cycle parameter symbol min. typ. max. unit notes ale low to low tdar 3 tcp - ? - 3 tcp + ? ns 1, 2 low to data valid tdda - - 4 tcp ns 1 data hold from high tddh 0 - 2 tcp ns data float from high tddz 0 - 2 tcp ns pulse width tdrd 6 tcp - ? 6 tcp - ns 2 notes: 1. data memory access time is 8 tcp. 2. " ? " (due to buffer driving delay and wire loading) is 20 ns. 20.3.4 data write cycle parameter symbol min. typ. max. unit ale low to low tdaw 3 tcp - ? - 3 tcp + ? ns data valid to low tdad 1 tcp - ? - - ns psen psen rd wr
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 72 - revision a1 3 data hold from high tdwd 1 tcp - ? - - ns pulse width tdwr 6 tcp - ? 6 tcp - ns note: " ? " (due to buffer driving delay and wire loading) is 20 ns. 20.3.5 port access cycle parameter symbol min. typ. max . unit port input setup to ale low tpds 1 tcp - - ns port input hold from ale low tpdh 0 - - ns port output to ale tpda 1 tcp - - ns note: ports are read during s5p2, and output data becomes available at the end of s6p2. the timing data are referenced to ale, since it provides a convenient reference. wr
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 73 - revision a1 3 20.4 timing waveforms 20.4.1 program fetch cycle 20.4.2 data read cycle s1 xtal1 s2 s3 s4 s5 s6 s1 s2 s3 s4 s5 s6 ale port 2 a0-a7 a0-a7 data a0-a7 code t a0-a7 data code port 0 psen pdh, t pdz t pda t aah t aas t psw t apl t alw s2 s3 s5 s6 s1 s2 s3 s4 s5 s6 s1 s4 xtal1 ale psen data a8-a15 port 2 port 0 a0-a7 rd t ddh, t ddz t dda t drd t dar
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 74 - revision a1 3 20.4.3 data write cycle 20.4.4 port access cycle s2 s3 s5 s6 s1 s2 s3 s4 s1 s5 s6 s4 xtal1 ale psen a8-a15 data out port 2 port 0 a0-a7 wr t t daw dad t dwr t dwd xtal1 ale s5 s6 s1 data out t t port input t sample pda pdh pds
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 75 - revision a1 3 20.4.5 reset pin access cycle v s s v d d p o f i n t e r n a l r e s e t p o w e r 1 = r e s e t s t a t e 0 = c p u f r e e r u n n i n g ~ 0 . 7 v r e s e t p i n a l e c r y s t a l c l o c k 6 5 5 3 6 c r y s t a l c l o c k ~ 2 . 0 v 1 2 c r y s t a l c l o c k = 1 m a c h i n e c y c l e 2 4 c r y s t a l c l o c k
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 76 - revision a1 3 21 application circuits 21.1 external program memory and crystal figure a 21.2 expanded external data memory and oscillator figure b a2 ad4 a5 ad0 a5 a9 a3 ad7 a7 ad1 a15 a4 ad6 a1 ad2 a14 a1 ad1 a3 ad3 ale r a10 ad3 a4 ad5 ad4 c1 a13 a15 ad7 vcc a0 cry stal rst a11 a9 74373 3 2 4 5 7 6 8 9 13 12 14 15 17 16 18 19 1 11 d0 q0 d1 q1 d2 q2 d3 q3 d4 q4 d5 q5 d6 q6 d7 q7 oc g ad4 a6 c2 psen 8.2k a8 a12 ad0 a2 w78i052ddg-40dip a11 a14 ad5 ad2 a7 a12 ad6 ad3 ad6 a6 w78i054ddg-40dip 31 19 18 9 12 13 14 15 1 2 3 4 5 6 7 8 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 17 16 29 30 11 10 20 40 ea xtal1 xtal2 rst p3.2/int0 p3.3/int1 p3.4/t0 p3.5/t1 p1.0/t2 p1.1/t2ex p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p2.6 p2.7 rd/p3.7 wr/p3.6 psen ale txd/p3.1 rxd/p3.0 vss vdd a10 ad7 ad2 ad5 vcc a8 a0 ad0 ad1 10uf a13 64kb rom 10 9 8 7 6 5 4 3 25 24 21 23 2 26 27 1 20 22 11 12 13 15 16 17 18 19 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 ce oe o0 o1 o2 o3 o4 o5 o6 o7 ad0 a0 a10 vcc ad4 ad6 8.2k ad3 a13 a0 a2 64kb ram 12 11 10 9 8 7 6 5 27 26 23 25 4 28 3 31 13 14 15 17 18 19 20 21 22 30 24 29 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 d0 d1 d2 d3 d4 d5 d6 d7 cs1 cs2 oe we ad5 a2 a11 ad1 a15 a14 ad4 ad2 a5 ad3 a15 ad4 a12 a4 a4 ad2 ad7 ad2 a14 ad6 /wr vcc ad5 rst a1 ad0 ad0 /rd a1 a8 a6 a5 vcc w78i054ddg-40dip 31 19 18 9 12 13 14 15 1 2 3 4 5 6 7 8 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 17 16 29 30 11 10 20 40 ea xtal1 xtal2 rst p3.2/int0 p3.3/int1 p3.4/t0 p3.5/t1 p1.0/t2 p1.1/t2ex p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p2.6 p2.7 rd/p3.7 wr/p3.6 psen ale txd/p3.1 rxd/p3.0 vss vdd a9 ale a9 a13 vcc oscillator ad3 ad7 ad5 a3 w78i052ddg-40dip a10 ad6 a3 a7 10uf a12 ad1 ad1 a7 74373 3 2 4 5 7 6 8 9 13 12 14 15 17 16 18 19 1 11 d0 q0 d1 q1 d2 q2 d3 q3 d4 q4 d5 q5 d6 q6 d7 q7 oc g a6 a11 ad7 a8
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 77 - revision a1 3 21.3 internal program memory and oscillator for eft application figure c 21.4 reference value of xtal crystal c1 c2 r 6 mhz 68 p 68 p - 16 mhz 47 p 47 p - 24 mhz 20 p 20 p - 32 mhz 10p 10p 6.8k 40 mhz 5p 5p 4.7k above table shows the reference values for crystal applications. notes: 1. c1, c2, r components refer to figure a ,c 2. crystal layout must get close to xtal1 and xtal2 pins on user's application board. a6 ad5 ad6 c19 a8 a3 a12 ad0 a2 ad6 74373 3 2 4 5 7 6 8 9 13 12 14 15 17 16 18 19 1 11 d0 q0 d1 q1 d2 q2 d3 q3 d4 q4 d5 q5 d6 q6 d7 q7 oc g vcc ad1 ad3 ad3 a10 a2 10k cry stal a9 a10 ad1 c18 ad4 ad2 vcc ad5 rst a13 a14 w78i054ddg-40dip 31 19 18 9 12 13 14 15 1 2 3 4 5 6 7 8 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 17 16 29 30 11 10 20 40 ea xtal1 xtal2 rst p3.2/int0 p3.3/int1 p3.4/t0 p3.5/t1 p1.0/t2 p1.1/t2ex p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p2.6 p2.7 rd/p3.7 wr/p3.6 psen ale txd/p3.1 rxd/p3.0 vss vdd a4 ad0 a1 ad7 ad0 /wr a6 a9 a1 a14 /rd ad6 ad2 a5 a8 a5 ad4 8.2k a15 ad2 ad7 a13 a12 a15 r a11 ale vcc a3 ad5 a0 ad3 10uf a11 a7 64kb ram 12 11 10 9 8 7 6 5 27 26 23 25 4 28 3 31 13 14 15 17 18 19 20 21 22 30 24 29 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 d0 d1 d2 d3 d4 d5 d6 d7 cs1 cs2 oe we w78i052ddg-40dip ad4 a0 a4 ad1 a7 ad7
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 78 - revision a1 3 22 application note in - system programming software examples this application note illustrates the in - system programmability of the microco ntroller. in this example, microcontroller will boot from 2k ldrom bank enter in - system programming mode for programming the contents of aprom, this sample to erase aprom, erase verify aprom, read one byte for aprom, write one byte for aprom, read cid/did. . example : base on keil c51 compiler $nomod51 #include eapage data 0beh chpcon data 0bfh sfral data 0c4h sfrah data 0c5h sfrfd data 0c6h sfrcn data 0c7h ;cpu clock = 12mhz/12t mode read_time equ 1 program_time equ 50 erase_time equ 5000 ;for w78e(i)054d aprom_end_address equ 03800h ;for w78e(i)052d ;aprom_end_address equ 02000h flash_st andby equ 00111111b read_cid equ 00001011b read_did equ 00001100b erase_rom equ 00100010b erase_verify equ 00001001b program_rom equ 00100001b program_verify_rom equ 00001010 b read_rom equ 00000000b org 03800h mov sp,#060h mov tmod,#01h ;set timer0 as mode1
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 79 - revision a1 3 call read_company_id call read_device_id_high call read_device_id_low call erase_aprom ca ll erase_verify_rom call program_aprom call program_verify_aprom call software_reset sjmp $ ;************************************************************************ ; * read_company_id ;************************************** ********************************** read_company_id: mov sfrcn,#read_cid mov tl0,#low (65536 - read_time) mov th0,#high(65536 - read_time) setb tr0 mov chpcon,#00000011b clr tf0 clr tr0 mov a,sfrf d ;check read company id cjne a,#0dah,cid_error ret cid_error: mov p1,#01h sjmp $ ;************************************************************************ ; * read device id high ;************************************ ************************************ read_device_id_high: mov sfral,#0ffh mov sfrah,#0ffh mov sfrcn,#read_did mov tl0,#low (65536 - read_time) mov th0,#high(65536 - read_time) setb tr0 mov chpcon,#0000 0011b clr tf0 clr tr0 mov a,sfrfd ;read device id high byte ret ;************************************************************************* ; * read device id low ;**************************************************** ******************** * read_device_id_low:
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 80 - revision a1 3 mov sfral,#0feh mov sfrah,#0ffh mov sfrcn,#read_did mov tl0,#low (65536 - read_time) mov th0,#high(65536 - read_time) setb tr0 mov chpcon,#00000011b clr tf0 clr tr0 mov a,sfrfd ;read device id low byte ret ;************************************************************************ ;* flash standby mode ;*********************************************************************** * standby: mov sfrcn,#flash_standby mov sfrfd,#0ffh mov sfral,#0ffh mov sfrah,#0ffh setb tr0 mov chpcon,#00000011b clr tf0 clr tr0 ret ;***************************************************** ******************* ;* erase aprom ;************************************************************************ erase_aprom: mov eapage,#01h ;set eapage is aprom mov sfrcn,#erase_rom mov tl0,#low (65536 - erase_time) mov th0,#high(65536 - erase_time) setb tr0 mov chpcon,#00000011b mov eapage,#00h ;clear eapage clr tf0 clr tr0 ret ;************************************************************************ ; * verify aprom bank ;************************************************************************ erase_verify_rom: mov sfrcn,#erase_verify mov dptr,#0000h er_lp:
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 81 - revision a1 3 mov tl0,#low (65536 - read_time) mov th0,#high(65536 - read_time) mov sfral ,dpl mov sfrah,dph setb tr0 mov chpcon,#00000011b clr tf0 clr tr0 mov a,sfrfd cjne a,#0ffh,erase_verify_error inc dptr mov r0,dpl cjne r0,#low (aprom_end_address),er_lp mov r1,dph cjne r1,#high(aprom_end_address),er_lp ret erase_verify_error: mov p1,#02h sjmp $ ;************************************************************************** ;*pro gramming aprom bank, aprom write 55h,aah,55h,aah........ ;************************************************************************** program_aprom: mov sfrcn,#program_rom mov dptr,#0000h mov a,#055h wr_lp: mov th0,#high(6553 6 - program_time) mov tl0,#low (65536 - program_time) mov sfrfd,a mov sfral,dpl mov sfrah,dph setb tr0 mov chpcon,#00000011b clr tf0 clr tr0 cpl a inc dptr mov r0,dpl cj ne r0,#low (aprom_end_address),wr_lp mov r1,dph cjne r1,#high(aprom_end_address),wr_lp ret ;************************************************************************** ;*program verify aprom bank, read aprom 55h, aah,55h,aah........
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 82 - revision a1 3 ;************************************************************************** program_verify_aprom: mov sfrcn,#program_verify_rom mov dptr,#0000h mov b,#055h rd_lp: mov th0,#high(65536 - read_time) mov tl0,#low (65536 - read_time) mov sfral,dpl mov sfrah,dph setb tr0 mov chpcon,#00000011b clr tf0 clr tr0 mov a,sfrfd cjne a,b,program_fail mov a,b cpl a mov b,a inc dptr mov r0,dpl cjne r0,#low (aprom_end_address),rd_lp mov r1,dph cjne r1,#high(aprom_end_address),rd_lp ret program_fail: mov p1,#0 3h sjmp $ ;************************************************************************** ;* programming completly, software reset cpu to aprom ;************************************************************************** software_reset: mov chpcon,#081h ;chpcon=081h, software reset to aprom. sjmp $ end
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 83 - revision a1 3 23 package dimensions 23.1 40 - pin dip 1.37 1.22 0.054 0.048 symbol min nom max max nom min dimension in inch dimension in mm a b c d e a l s a a 1 2 e 0.050 1.27 0.210 5.33 0.010 0.150 0.016 0.155 0.018 0.160 0.022 3.81 0.41 0.25 3.94 0.46 4.06 0.56 0.008 0.120 0.670 0.010 0.130 0.014 0.140 0.20 3.05 0.25 3.30 0.36 3.56 0.540 0.550 0.545 13.72 13.97 13.84 17.02 15.24 14.99 15.49 0.600 0.590 0.610 2.29 2.54 2.79 0.090 0.100 0.110 b 1 1 e e 1 2.055 2.070 52.20 52.58 0 15 0.090 2.29 0.650 0.630 16.00 16.51 15 0 seating plane e a 2 a c e base plane 1 a 1 e l a s 1 e d 1 b b 40 21 20 1
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 84 - revision a1 3 23.2 44 - pin plcc 23.3 44 - pin p qfp 44 40 39 29 28 18 17 7 6 1 l c 1 b 2 a h d d e b e h e y a a 1 seating plane d g g e symbol min nom max max nom min dimension in inch dimension in mm a b c d e h e l y a a 1 2 e b 1 h d g g d e 0.020 0.145 0.026 0.016 0.008 0.648 0.590 0.680 0.090 0.150 0.028 0.018 0.010 0.653 0.610 0.690 0.100 0.050 bsc 0.185 0.155 0.032 0.022 0.014 0.658 0.630 0.700 0.110 0.004 0.51 3.68 0.66 0.41 0.20 16.46 14.99 17.27 2.29 3.81 0.71 0.46 0.25 16.59 15.49 17.53 2.54 1.27 4.70 3.94 0.81 0.56 0.36 16.71 16.00 17.78 2.79 0.10 bsc 16.71 16.59 16.46 0.658 0.653 0.648 16.00 15.49 14.99 0.630 0.610 0.590 17.78 17.53 17.27 0.700 0.690 0.680
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 85 - revision a1 3 0.25 0.10 0.010 0.004 symbol min nom max max nom min dimension in inch dimension in mm a b c d e h d h e l y 0 a a l 1 1 2 e 0.006 0.15 - - 0.002 0.075 0.01 0.081 0.014 0.087 0.018 1.90 0.25 0.05 2.05 0.35 2.20 0.45 0.390 0.510 0.025 0.063 0.004 0 10 0.394 0.520 0.031 0.398 0.530 0.037 9.9 0.80 12.95 0.65 1.60 10.00 13.20 0.8 10.1 13.45 0.95 0.398 0.394 0.390 0.530 0.520 0.510 13.45 13.20 12.95 10.1 10.00 9.9 10 0 0.10 .0315 0.01 0.02 0.25 0.5 seating plane 11 22 12 see detail f e b a y 1 a a 2 l l 1 c e e h 1 d 44 h d 34 33 detail f
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 86 - revision a1 3 23.4 48 - pin l qfp
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 87 - revision a1 3 23.5 4 4 - pin t qfp
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 88 - revision a1 3 24 revision h istory version date page description a 01 august 14, 2008 - initial issued a02 november 3, 2008 - update dc table typ ing error. a03 december 15, 2008 - update config bit table, and isp boot a04 jan uary 7, 2007 70 update v il and v ih a05 march 9, 2009 43 update soft reset, only ld jump to ap function. a06 march 20 , 2009 18 - - 1. rename sfr register por (0x86h) to p0upr . 2. revise some typing errors in data sheet . 3. update dc table a07 april 2 2, 2009 68 1. revise type application circuit in data sheet. a08 june 30 , 2009 30 6 1 8 1 all pages 1. add the isp control table . 2. revise content of char. 17 . 3. modify the isp demo code . 4. remove the preliminary character for each page . a09 december 30 , 2009 68 77 1. revise the config bits description for bit4 , bit6 and bit7 . 2. add the timing for external reset pin. a10 oct ober 20, 201 1 28 70 1. revised the chpcon description 2. add ed description for 2 1 .4 reference value of xtal a1 1 apr il 18 , 201 2 7 3 1. removed 20.3 .6 character . a12 aug 31, 2012 1. removed w78e051d part number. 2. added tqfp44 package a13 jun 9, 2015 73 1. revised timing of data read cycle
w78e 0 5 4d/ w78e 052d data sheet publication release date: jun 9 , 20 15 - 89 - revision a1 3 important notice nuvoton products are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. such applications are deemed, insecure usage. insecure usage includes, but is not limited to: equipment for surgical implementation, a tomic energy control instruments, airplane or spaceship instruments, the control or operation of d y- namic, brake or safety systems designed for vehicular use, traffic signal instruments, all types of safety devices, and other applications intended to suppor t or sustain life. all insecure usage shall be made at customers risk, and in the event that third parties lay claims to nuvoton as a result of customers insecure usage, customer shall indemnify the damages and liabilities thus incurred by nuvoton.


▲Up To Search▲   

 
Price & Availability of W78E052DDG

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X